Part Number Hot Search : 
MC1452 AR258 RN1903FE SPACE N74F260 LBC847 UM6601CR UPG2179
Product Description
Full Text Search
 

To Download UPD17705GC-XXX-3B9 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  the mark shows major revised points. mos integrated circuit document no. u11624ej2v0ds00 (2nd edition) date published december 1996 n printed in japan the m pd17704, 17705, 17707, 17708, and 17709 are 4-bit single-chip cmos microcontrollers containing hardware for digital tuning systems. provided with a wealth of hardware, these microcontrollers are available in many variations of rom and ram capacities to support various applications. therefore, a high-performance, multi-function digital tuning system can be configured with only one chip. in addition, a one-time prom model, m pd17p709, which can be written only once and therefore is ideal for program evaluation and small-scale production of a m pd17704, 17705, 17707, 17708, or 17709 system, is also available. features m pd17704 m pd17705 m pd17707 m pd17708 m pd17709 program memory (rom) 16k bytes 24k bytes 32k bytes (8192 16 bits) (12288 16 bits) (16384 16 bits) general purpose data 672 4 bits 1120 4 bits 1776 4 bits memory (ram) ? instruction execution time ? many interrupts 1.78 m s (with f x = 4.5-mhz crystal oscillator) external : 6 sources ? pll frequency synthesizer internal : 6 sources dual modulus prescaler (130 mhz max.), ? power-on reset, ce reset, and power failure programmable divider, phase comparator, charge detection circuit pump ? supply voltage: v dd = 5 v 10 % ? abundant peripheral hardware units general-purpose i/o ports, serial interfaces, a/d converter, d/a converter (pwm output), beep output, frequency counter unless otherwise specified, the m pd17709 is treated as the representative model in this document. 4-bit single-chip microcontrollers with dedicated hardware for digital tuning system the information in this document is subject to change without notice. m pd17704, 17705, 17707, 17708, 17709 1996 data sheet
m pd17704, 17705, 17707, 17708, 17709 2 ordering information part number package m pd17704gc- -3b9 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17705gc- -3b9 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17707gc- -3b9 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17708gc- -3b9 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17709gc- -3b9 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) remark indicates a rom code number. functional outline part number m pd17704 m pd17705 m pd17707 m pd17708 m pd17709 item program memory (rom) 16k bytes 24k bytes (12288 16 bits) 32k bytes (16384 16 bits) (8192 16 bits) general-purpose data memory (ram) 672 4 bits 1120 4 bits 1176 4 bits instruction execution time 1.78 m s (with f x = 4.5-mhz crystal oscillator) general-purpose port ? i/o port : 46 pins ? input port : 12 pins ? output port: 4 pins stack level ? address stack : 15 levels ? interrupt stack: 4 levels ? dbf stack : 4 levels (can be manipulated via software) interrupt ? external: 6 sources (falling edge of ce pin, int0 through int4) ? internal : 6 sources (timers 0 through 3, serial interfaces 0 and 1) timer 5 channels ? basic timer (clock: 10, 20, 50, 100 hz) : 1 channel ? 8-bit timer with gate counter (clock: 1 k, 2 k, 10 k, 100 khz): 1 channel ? 8-bit timer (clock: 1 k, 2 k, 10 k, 100 khz) : 2 channels ? 8-bit timer multiplexed with pwm (clock: 440 hz, 4.4 khz) : 1 channel a/d converter 8 bits 6 channels (hardware mode and software mode selectable) d/a converter (pwm) 3 channels (8-bit or 9-bit resolution selectable by software) output frequency: 4.4 khz, 440 hz (with 8-bit pwm selected) 2.2 khz, 220 hz (with 9-bit pwm selected) serial interface 2 units (3 channels) ? 3-wire serial i/o : 2 channels ? 2-wire serial i/o/i 2 c bus: 1 channel pll frequency division mode ? direct division mode (vcol pin (mf mode) : 0.5 to 3 mhz) synthesizer ? pulse swallow mode (vcol pin (hf mode) : 10 to 40 mhz) (vcoh pin (vhf mode): 60 to 130 mhz) reference frequency 13 types selectable (1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 18, 20, 25, 50 khz) charge pump two error-out output pins (eo0, eo1) phase comparator unlock status detectable by program
3 m pd17704, 17705, 17707, 17708, 17709 part number m pd17704 m pd17705 m pd17707 m pd17708 m pd17709 item frequency counter ? intermediate frequency (if) measurement p1c0/fmifc pin: in fmif mode 10 to 11 mhz in amif mode 0.4 to 0.5 mhz p1c1/amifc pin: in amif mode 0.4 to 0.5 mhz ? external gate width measurement p2a1/fcg1, p2a0/fcg0 pin beep output 2 pins output frequency: 1 khz, 3 khz, 4 khz, 6.7 khz (beep0 pin) 67 hz, 200 hz, 3 khz, 4 khz (beep1 pin) reset ? power-on reset (on power application) ? reset by reset pin ? watchdog timer reset can be set only once on power application: 65536 instruction, 131072 instruction, or no-use selectable ? stack pointer overflow/underflow reset can be set only once on power application: interrupt stack or address stack selectable ? ce reset (ce pin low ? high level) ce reset delay timing can be set. ? power failure detection function standby ? clock stop mode (stop) ? halt mode (halt) supply voltage ? pll operation: v dd = 4.5 to 5.5 v ? cpu operation: v dd = 3.5 to 5.5 v package 80-pin plastic qfp (14 14 mm, 0.65 mm pitch)
m pd17704, 17705, 17707, 17708, 17709 4 pin configuration (top view) 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17704gc- -3b9 m pd17705gc- -3b9 m pd17707gc- -3b9 m pd17708gc- -3b9 m pd17709gc- -3b9 22 gnd2 p0d3/ad3 p0d2/ad2 p0d1/ad1 p0d0/ad0 p1c3/ad5 p1c2/ad4 p1c1/amifc p1c0/fmifc v dd 1 vcoh vcol gnd1 eo0 eo1 test p1d3 p1d2 p1d1/beep1 p1d0/beep0 int2 p1a3/int4 p1a2/int3 p1a1 p1a0/tm0g p3a3 p3a2 p3a1 p3a0 p3b3 p3b2 p3b1 p3b0 p2a2 p2a1/fcg1 p2a0/fcg0 p1b3 p1b2/pwm2 p1b1/pwm1 p1b0/pwm0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 p0c2 p0c3 p2c0 p2c1 p2c2 p2c3 p3d0 p3d1 p3d2 p3d3 p3c0 p3c1 p3c2 p3c3 p2b0 p2b1 p2b2 p2b3 int0 int1 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 21 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 reset v dd 0 ce x in x out gnd0 reg p2d0 p2d1 p2d2 p0b0/si1 p0b1/so1 p0b2/sck1 p0b3/si0 p0a0/so0 p0a1/sck0 p0a2/scl p0a3/sda p0c0 p0c1 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61
5 m pd17704, 17705, 17707, 17708, 17709 pin name ad0-ad5 : a/d converter input amifc : am frequency counter input beep0, beep1 : beep output ce : chip enable eo0, eo1 : error-out output fcg0, fgc1 : frequency counter gate input fmifc : fm frequency counter input gnd0-gnd2 : ground 0 to 2 int0-int4 : external interrupt input pwm0-pwm2 : d/a converter output p0a0-p0a3 : port 0a p0b0-p0b3 : port 0b p0c0-p0c3 : port 0c p0d0-p0d3 : port 0d p1a0-p1a3 : port 1a p1b0-p1b3 : port 1b p1c0-p1c3 : port 1c p1d0-p1d3 : port 1d p2a0-p2a2 : port 2a p2b0-p2b3 : port 2b p2c0-p2c3 : port 2c p2d0-p2d2 : port 2d p3a0-p3a3 : port 3a p3b0-p3b3 : port 3b p3c0-p3c3 : port 3c p3d0-p3d3 : port 3d reg : cpu regulator reset : reset input sck0, sck1 : 3-wire serial clock i/o scl : 2-wire serial clock i/o sda : 2-wire serial data i/o si0, si1 : 3-wire serial data input so0, so1 : 3-wire serial data output test : test input tm0g : timer 0 gate input vcoh : local oscillation high input vcol : local oscillation low input v dd 0, v dd 1 : power supply x in , x out : main clock oscillation
m pd17704, 17705, 17707, 17708, 17709 6 block diagram 4 4 ad0/p0d0 ad5/p1c3 ad1/p0d1 ad2/p0d2 ad3/p0d3 ad4/p1c2 4 4 4 4 4 4 4 3 4 4 3 4 4 4 p0a0-p0a3 p0b0-p0b3 p0c0-p0c3 p0d0-p0d3 p1a0-p1a3 p1b0-p1b3 p1c0-p1c3 p1d0-p1d3 p2a0-p2a2 p2b0-p2b3 p2c0-p2c3 p2d0-p2d2 p3a0-p3a3 p3b0-p3b3 p3c0-p3c3 p3d0-p3d3 pwm2/p1b2 pwm0/p1b0 pwm1/p1b1 port a/d converter d/a converter 8-bit timer3 basic timer rf ram 672 4 bits ( pd17704, 17705) 1120 4 bits ( pd17707, 17708) 1776 4 bits ( pd17709) sysreg alu instruction decoder rom 8192 16 bits ( pd17704) 12288 16 bits ( pd17705, 17707) 16384 16 bits ( pd17708, 17709) program counter stack vcoh vcol eo0 eo1 pll so0/p0a0 sck0/p0a1 scl/p0a2 sda/p0a3 si0/p0b3 sck1/p0b2 so1/p0b1 si1/p0b0 beep0/p1d0 beep1/p1d1 int0 int1 int2 int3/p1a2 int4/p1a3 fcg0/p2a0 fcg1/p2a1 fmifc/p1c0 amifc/p1c1 tm0g/p1a0 x in x out ce reset v dd 0, v dd 1 reg v cpu cpu peripheral gnd0-gnd2 serial interface0 serial interface1 beep interrupt control frequency counter 8-bit timer0 gate counter 8-bit timer1 8-bit timer2 osc reset regulator m m m m m m
7 m pd17704, 17705, 17707, 17708, 17709 table of contesnts 1. pin functions ................................................................................................................ .............. 11 1.1 pin function list ........................................................................................................... ....... 11 1.2 equivalent circuits of pins ................................................................................................. .16 1.3 connections of unused pins .............................................................................................. 21 1.4 cautions on using ce, int0 through int4, and reset pins .......................................... 23 1.5 cautions on using test pin ............................................................................................... 23 2. program memory (rom) ......................................................................................................... .24 2.1 outline of program memory ................................................................................................ 24 2.2 program memory .............................................................................................................. .... 25 2.3 program counter ............................................................................................................. ..... 26 2.4 flow of program ............................................................................................................. ...... 26 2.5 cautions on using program memory ................................................................................ 29 3. address stack (ask) .......................................................................................................... ...... 30 3.1 outline of address stack .................................................................................................... .30 3.2 address stack register (asr) ............................................................................................ 30 3.3 stack pointer (sp) .......................................................................................................... ...... 32 3.4 operation of address stack ................................................................................................ 33 3.5 cautions on using address stack ...................................................................................... 34 4. data memory (ram) ............................................................................................................ ....... 35 4.1 outline of data memory ...................................................................................................... .35 4.2 configuration and function of data memory ................................................................... 38 4.3 data memory addressing .................................................................................................... 42 4.4 cautions on using data memory ........................................................................................ 43 5. system registers (sysreg) ................................................................................................... 4 4 5.1 outline of system registers ............................................................................................... 44 5.2 system register list ........................................................................................................ .... 45 5.3 address register (ar) ....................................................................................................... .. 46 5.4 window register (wr) ........................................................................................................ .48 5.5 bank register (bank) ........................................................................................................ .49 5.6 index register (ix) and data memory row address pointer (mp: memory pointer) .... 50 5.7 general register pointer (rp) ............................................................................................. 52 5.8 program status word (psword) ....................................................................................... 54 6. general register (gr) ........................................................................................................ .... 56 6.1 outline of general register ................................................................................................. 56 6.2 general register ............................................................................................................ ...... 56 6.3 generating address of general register by each instruction ........................................ 57 6.4 cautions on using general register ................................................................................. 57
m pd17704, 17705, 17707, 17708, 17709 8 7. alu (arithmetic logic unit) block ............................................................................................ .58 7.1 outline of alu block ....................................................................................................... ... 58 7.2 configuration and function of each block ....................................................................... 59 7.3 alu processing instruction list ......................................................................................... 59 7.4 cautions on using alu ....................................................................................................... 63 8. register file (rf) ......................................................................................................... ............... 64 8.1 outline of register file .................................................................................................... .... 64 8.2 configuration and function of register file .................................................................... 65 8.3 control registers ........................................................................................................... ...... 66 8.4 port input/output selection registers .............................................................................. 78 8.5 cautions on using register file ......................................................................................... 84 9. data buffer (dbf) .......................................................................................................... ............. 85 9.1 outline of data buffer ...................................................................................................... .... 85 9.2 data buffer ................................................................................................................. ........... 86 9.3 relationships between peripheral hardware and data buffer ........................................ 87 9.4 cautions on using data buffer ........................................................................................... 90 10. data buffer stack ........................................................................................................... ........ 91 10.1 outline of data buffer stack ............................................................................................... .91 10.2 data buffer stack register ................................................................................................. .91 10.3 data buffer stack pointer .................................................................................................. .. 93 10.4 operation of data buffer stack ........................................................................................... 94 10.5 using data buffer stack .................................................................................................... .. 95 10.6 cautions on using data buffer stack ................................................................................ 95 11. general-purpose port ........................................................................................................ ... 96 11.1 outline of general-purpose port ......................................................................................... 96 11.2 general-purpose i/o port (p0a, p0b, p0c, p1d, p2a, p2b, p2c, p2d, p3a, p3b, p3c, p3d) ...................................................................................................................... ........ 99 11.3 general-purpose input port (p0d, p1a, p1c) ................................................................... 113 11.4 general-purpose output port (p1b) .................................................................................. 116 12. interrupt ................................................................................................................. .................... 117 12.1 outline of interrupt block ................................................................................................. ... 117 12.2 interrupt control block .................................................................................................... .... 119 12.3 interrupt stack register................................................................................................... .... 133 12.4 stack pointer, address stack registers, and program counter .................................... 137 12.5 interrupt enable flip-flop (inte) ........................................................................................ 13 7 12.6 accepting interrupt ........................................................................................................ ...... 138 12.7 operations after interrupt has been accepted ................................................................ 143 12.8 returning from interrupt routine ....................................................................................... 143 12.9 external interrupts (ce and int0 through int4 pins) ...................................................... 144 12.10 internal interrupts ....................................................................................................... ......... 147 13. timers ...................................................................................................................... ...................... 148 13.1 outline of timers .......................................................................................................... ........ 148
9 m pd17704, 17705, 17707, 17708, 17709 13.2 basic timer 0 .............................................................................................................. .......... 150 13.3 timer 0 .................................................................................................................... .............. 163 13.4 timer 1 .................................................................................................................... .............. 172 13.5 timer 2 .................................................................................................................... .............. 179 13.6 timer 3 .................................................................................................................... .............. 186 14. a/d converter ............................................................................................................... ............. 193 14.1 outline of a/d converter ................................................................................................... .. 193 14.2 input selection block ...................................................................................................... ..... 194 14.3 compare voltage generation and compare blocks ........................................................ 196 14.4 comparison timing chart ................................................................................................... 1 99 14.5 using a/d converter ........................................................................................................ .... 200 14.6 cautions on using a/d converter ...................................................................................... 201 14.7 status at reset ............................................................................................................ ......... 201 15. d/a converter (pwm mode) .................................................................................................... .. 202 15.1 outline of d/a converter ................................................................................................... .. 202 15.2 pwm clock selection register ........................................................................................... 203 15.3 pwm output selection block .............................................................................................. 204 15.4 duty setting block ......................................................................................................... ...... 207 15.5 clock generation block ..................................................................................................... .. 211 15.6 d/a converter output wave ................................................................................................ 21 1 15.7 example of using d/a converter ........................................................................................ 214 15.8 status at reset ............................................................................................................ ......... 215 16. serial interfaces ........................................................................................................... .......... 216 16.1 outline of serial interfaces ............................................................................................... ... 216 16.2 serial interface 0 ......................................................................................................... ......... 217 16.3 serial interface 1 ......................................................................................................... ......... 245 17. pll frequency synthesizer .................................................................................................. 2 55 17.1 outline of pll frequency synthesizer.............................................................................. 255 17.2 input selection block and programmable divider ........................................................... 256 17.3 reference frequency generator ......................................................................................... 260 17.4 phase comparator ( f -det), charge pump, and unlock ff ............................................. 262 17.5 pll disabled status ........................................................................................................ .... 266 17.6 using pll frequency synthesizer ..................................................................................... 267 17.7 status at reset ............................................................................................................ ......... 271 18. frequency counter ........................................................................................................... ...... 272 18.1 outline of frequency counter ............................................................................................. 27 2 18.2 input/output selection block and gate time control block ........................................... 273 18.3 start/stop control block and if counter .......................................................................... 276 18.4 using if counter ........................................................................................................... ....... 283 18.5 using external gate counter .............................................................................................. 28 5 18.6 status at reset ............................................................................................................ ......... 286
m pd17704, 17705, 17707, 17708, 17709 10 19. beep ........................................................................................................................ ........................ 287 19.1 outline of beep ............................................................................................................ ........ 287 19.2 i/o selection block and output selection block .............................................................. 288 19.3 clock selection block and clock generation block ........................................................ 290 19.4 output waveform of beep .................................................................................................. 29 1 19.5 status at reset ............................................................................................................ ......... 291 20. standby ..................................................................................................................... ................... 292 20.1 outline of standby function ............................................................................................... 2 92 20.2 halt function .............................................................................................................. .......... 293 20.3 clock stop function ........................................................................................................ .... 299 20.4 device operation in halt and clock stop status .............................................................. 301 20.5 cautions on processing of each pin in halt and clock stop status .............................. 301 20.6 device operation control function of ce pin .................................................................. 303 21. reset ....................................................................................................................... ....................... 306 21.1 outline of reset ........................................................................................................... ......... 306 21.2 ce reset ................................................................................................................... ............ 307 21.3 power-on reset ............................................................................................................. ...... 313 21.4 relationship between ce reset and power-on reset .................................................... 316 21.5 reset by reset pin ......................................................................................................... .... 320 21.6 wdt&sp reset ............................................................................................................... ...... 321 21.7 power failure detection .................................................................................................... .. 327 22. instruction set ............................................................................................................. ............ 332 22.1 outline of instruction set ................................................................................................. ... 332 22.2 legend ..................................................................................................................... ............. 333 22.3 instruction list ........................................................................................................... .......... 334 22.4 assembler (ra17k) embedded macro instruction .......................................................... 336 23. reserved symbols ............................................................................................................ ....... 337 23.1 data buffer (dbf) .......................................................................................................... ....... 337 23.2 system registers (sysreg) ............................................................................................... 337 23.3 port registers ............................................................................................................. .......... 338 23.4 register file (control registers) ........................................................................................ 34 0 23.5 peripheral hardware registers ........................................................................................... 345 23.6 others ..................................................................................................................... ............... 345 24. electrical characteristics ................................................................................................ 34 6 25. package drawing ............................................................................................................. ........ 349 26. recommended soldering conditions .............................................................................. 350 appendix a. cautions on connecting crystal resonator ........................................... 351 appendix b. development tools ............................................................................................... 35 2
11 m pd17704, 17705, 17707, 17708, 17709 1. pin functions 1.1 pin function list pin no. symbol function output form 1 int2 edge-detectable vectored interrupt input pins. rising or falling edge can be C 41 int1 specified. 42 int0 2 p1a3/int4 port 1a multiplexed with external interrupt request signal input and event C 3 p1a2/int3 signal input pins. 4 p1a1 ? p1a3 through p1a0 5 p1a0/tm0g ? 4-bit input port ? int4, int3 ? edge-detectable vectored interrupt ? tm0g ? input for gate of 8-bit timer 0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained (p1a3 through p1a0) (p1a3 through p1a0) 6 p3a3 4-bit i/o port. cmos | | can be set in input or output mode in 4-bit units. push-pull 9 p3a0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained 10 p3b3 4-bit i/o port. cmos | | can be set in input or output mode in 4-bit units. push-pull 13 p3b0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained 14 p2a2 port 2a multiplexed with external gate counter input pins. cmos 15 p2a1/fcg1 ? p2a2 through p2a0 push-pull 16 p2a0/fcg0 ? 3-bit i/o port ? can be set in input or output mode in 1-bit units. ? fcg1, fcg0 ? input for external gate counter at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained (p2a2 through p2a0) (p2a2 through p2a0) (p2a2 through p2a0) (p2a2 through p2a0)
m pd17704, 17705, 17707, 17708, 17709 12 pin no. symbol function output form 17 p1b3 port 1b multiplexed with d/a converter output pins. n-ch 18 p1b2/pwm2 ? p1b3 through p1b0 open-drain | | ? 4-bit output port (12 v) 20 p1b0/pwm0 ? pwm2 through p2m0 ? 8- or 9-bit d/a converter output at reset with clock stopped power-on reset wdt&sp reset ce reset outputs low level outputs low level retained retained (p1b3 through p1b0) (p1b3 through p1b0) (p1b3 through p1b0) 21 gnd2 ground C 33 gnd1 75 gnd0 22 p0d3/ad3 port 0d multiplexed with a/d converter input pins C | | ? p0d3 through p0d0 25 p0d0/ad0 ? 4-bit input port ? can be connected with pull-down resistor in 1-bit units. ? ad3 through ad0 ? analog input of a/d converter with 8-bit resolution at reset with clock stopped power-on reset wdt&sp reset ce reset input with pull-down input with pull-down retained retained resistor resistor (p0d3 through p0d0) (p0d3 through p0d0) 26 p1c3/ad5 port 1c multiplexed with a/d converter input and if counter input pins. C 27 p1c2/ad4 ? p1c3 through p1c0 28 p1c1/amifc ? 4-bit input port 29 p1c0/fmifc ? ad5, ad4 ? analog input to a/d converter with 8-bit resolution ? fmifc, amifc ? input to frequency counter at reset with clock stopped power-on reset wdt&sp reset ce reset input input ? p1c3/ad5, ? p1c3/ad5, (p1c3 through p1c0) (p1c3 through p1c0) p1c2/ad4 p1c2/ad4 retained retained ? p1c1/amifc, ? p1c1/amifc, p1c0/fmifc p1c0/fmifc input input (p1c1, p1c0) (p1c1, p1c0)
13 m pd17704, 17705, 17707, 17708, 17709 pin no. symbol function output form 30 v dd 1 power supply. supply the same voltage to these pins. C 79 v dd 0 ? with cpu and peripheral function operating: 4.5 to 5.5 v ? with cpu operating : 3.5 to 5.5 v ? with clock stopped : 2.2 to 5.5 v 31 vcoh pll local oscillation (vco) frequency input. C 32 vcol ? vcoh ? active with vhf mode selected by program; otherwise, pulled down. ? vcol ? active with hf or mw mode selected by program; otherwise, pulled down. because the input of these pins goes into an ac amplifier, cut the dc component of the input signal with a capacitor. 34 eo0 output from charge pump of pll frequency synthesizer. outputs the divided cmos 35 eo1 frequency of local oscillation and the result of comparison of the phase 3-state difference of reference frequency. at reset with clock stopped power-on reset wdt&sp reset ce reset high-impedance high-impedance high-impendance high-impedance output output output output 36 test test input pin. C be sure to connect this pin to gnd. 37 p1d3 port 1d and beep output. cmos 38 p1d2 ? p1d3 through p1d0 push-pull 39 p1d1/beep1 ? 4-bit i/o port 40 p1d0/beep0 ? can be set in input or output mode in 1-bit units. ? beep1, beep0 ? beep output at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained ( p1d3 through p1d0) (p1d3 through p1d0) (p1d3 through p1d0) (p1d3 through p1d0) 43 p2b3 4-bit i/o port. cmos | | can be set in input or output mode in 1-bit units. push-pull 46 p2b0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained 47 p3c3 4-bit i/o port. cmos | | can be set in input or output mode in 4-bit units. push-pull 50 p3c0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained
m pd17704, 17705, 17707, 17708, 17709 14 pin no. symbol function output form 51 p3d3 4-bit i/o port. cmos | | can be set in input or output mode in 4-bit units. push-pull 54 p3d0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained 55 p2c3 4-bit i/o port. cmos | | can be set in input or output mode in 4-bit units. push-pull 58 p2c0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained 59 p0c3 4-bit i/o port. cmos | | can be set in input or output mode in 4-bit units. push-pull 62 p0c0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained 63 p0a3/dsa ports p0a and p0b are multiplexed with i/o of serial interface. n-ch 64 p0a2/scl ? p0a3 through p0a0 open-drain 65 p0a1/sck0 ? 4-bit i/o port cmos 66 p0a0/so0 ? can be set in input or output mode in 1-bit units. push-pull 67 p0b3/si0 ? p0b3 through p0b0 68 p0b2/sck1 ? 4-bit i/o port 69 p0b1/so1 ? can be set in input or output mode in 1-bit units. 70 p0b0/si1 ? sda, scl ? serial data and serial clock i/o of serial interface 0 in 2-wire serial i/o or i 2 c bus mode ? sck0, so0, si0 ? serial clock i/o, serial data output, and serial data input of serial interface 0 in 3-wire serial i/o mode ? sck1, so1, si1 ? serial clock i/o, serial data output, serial data input of serial interface 1 in 3-wire serial i/o mode at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained p0a3 through p0a0, p0a3 through p0a0, p0a3 through p0a0, p0a3 through p0a0, p0b3 through p0b0 p0b3 through p0b0 p0b3 through p0b0 p0b3 through p0b0 71 p2d2 3-bit i/o port. cmos | | can be set in input or output mode in 1-bit units. push-pull 73 p2d0 at reset with clock stopped power-on reset wdt&sp reset ce reset input input retained retained
15 m pd17704, 17705, 17707, 17708, 17709 pin no. symbol function output form 74 reg cpu regulator. C connect this pin to gnd via 0.1- m f capacitor. 76 x out ground pins of crystal resonator. C 77 x in 78 ce device operation-selection, ce reset, and interrupt signal input pin. C ? device operation-select when ce is high, pll frequency synthesizer can operate. when ce is low, pll frequency synthesizer is automatically disabled internally. ? ce reset when ce goes high, device is reset at rising edge of internal basic timer setting pulse. this pin also has reset timing delay function. ? interrupt vectored interrupt occurs at falling edge of this pin. 80 reset reset input C
m pd17704, 17705, 17707, 17708, 17709 16 1.2 equivalent circuits of pins (1) p0a (p0a1/sck0, p0a0/so0) p0b (p0b3/si0, p0b2/sck1, p0b1/so1, p0b0/si1) p0c (p0c3, p0c2, p0c1, p0c0) p1d (p1d3, p1d2, p1d1/beep1, p1d0/beep0) p2a (p2a2, p2a1/fcg1, p2a0/fcg0) p2b (p2b3, p2b2, p2b1, p2b0) (i/o) p2c (p2c3, p2c2, p2c1, p2c0) p2d (p2d2, p2d1, p2d0) p3a (p3a3, p3a2, p3a1, p3a0) p3b (p3b3, p3b2, p3b1, p3b0) p3c (p3c3, p3c2, p3c1, p3c0) p3d (p3d3, p3d2, p3d1, p3d0) note this is an internal signal that is output when the clock stop instruction is executed, and its circuit is designed not to increase the current consumption due to noise even if it is floated. v dd v dd ckstop note
17 m pd17704, 17705, 17707, 17708, 17709 (2) p0a (p0a3/sda, p0a2/scl) (i/o) note this is an internal signal that is output when the clock stop instruction is executed, and its circuit is designed not to increase the current consumption due to noise even if it is floated. (3) p1b (p1b3, p1b2/pwm2, p1b1/pwm1, p1b0/pwm0) (output) (4) p0d (p0d3/ad3, p0d2/ad2, p0d1/ad1, p0d0/ad0) (input) note this is an internal signal that is output when the clock stop instruction is executed, and its circuit is designed not to increase the current consumption due to noise even if it is floated. v dd ckstop note v dd ckstop note a/d converter p0dpld flag high-on resistance
m pd17704, 17705, 17707, 17708, 17709 18 (5) p1a (p1a1) (input) note this is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (6) p1c (p1c3/ad5, p1c2/ad4) (input) note this is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (7) p1c (p1c1/amifc, p1c0/fmifc) (input) note this is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. v dd a/d converter ckstop note v dd ckstop note v dd v dd v dd general-purpose port high-on resistance frequency counter ckstop note
19 m pd17704, 17705, 17707, 17708, 17709 (8) ce reset int0, int1, int2 (schmitt trigger input) p1a (p1a3/int4, p1a2/int3, p1a0/tm0g) (9) x out (output), x in (input) (10) eo1, eo0 (output) v dd v dd v dd high-on resistance internal clock high-on resistance x in x out v dd dwn up
m pd17704, 17705, 17707, 17708, 17709 20 (11) vcoh, vcol (input) v dd v dd high-on resistance high-on resistance
21 m pd17704, 17705, 17707, 17708, 17709 1.3 connections of unused pins it is recommended to connect unused pins as follows: table 1-1. connections of unused pins (1/2) pin name i/o mode recommended connections of unused pins port pin p0d3/ad3-p0d0/ad0 input individually connect to gnd via resistor note 1 . p1c3/ad5 p1c2/ad4 p1c1/amifc note 2 set in port mode and individually connect to v dd or gnd p1c0/fmifc note 2 via resistor note 1 . p1a3/int4 individually connect to gnd via resistor note 1 . p1a2/int3 p1a1 p1a0/tm0g p1b3 n-ch open-drain set to low-level output by software and then open. p1b2/pwm2-p1b0/pwm0 output p0a3/sda i/o note 3 set in general-purpose input port mode by software and p0a2/scl individually connect to v dd or gnd via resistor note 1 . p0a1/sck0 p0a0/so0 p0b3/si0 p0b2/sck1 p0b1/so1 p0b0/si1 p0c3-p0c0 p1d3 p1d2 p1d1/beep1 p1d0/beep0 p2a2 p2a1/fcg1 p2a0/fcg0 p2b3-p2b0 p2c3-p2c0 p2d2-p2d0 notes 1. if a pin is externally pulled up (connected to v dd via resistor) or pulled down (connected to gnd via resistor) with a high resistance, the pin almost enters a high-impedance state, increasing the current (through-current) consumption of the port. generally, the resistance of a pull-up or pull- down resistor is several 10 k w , though it depends on the application circuit. 2. do not set these pins as amifc and fmifc pins; otherwise, the current consumption will increase. 3. the i/o ports are set in the general-purpose i/o port mode at power-on reset, when reset by the reset pin, or when reset due to overflow or underflow of the watchdog timer or the stack.
m pd17704, 17705, 17707, 17708, 17709 22 table 1-1. connections of unused pins (2/2) pin name i/o mode recommended connections of unused pins port pin p3a3-p3a0 i/o note 2 set in general-purpose input port mode by software and p3b3-p3b0 individually connect to v dd or gnd via resistor note 1 . p3c3-p3c0 p3d3-p3d0 pins other ce input connect to v dd via resistor note 1 . than port eo1 output open pins eo0 int0-int2 input individually connect to gnd via resistor note 1 . reset input connect to v dd via resistor note 1 . test C directly connect to gnd. vcoh input disable pll via software and open. vcol notes 1. if a pin is externally pulled up (connected to v dd via resistor) or pulled down (connected to gnd via resistor) with a high resistance, the pin almost enters a high-impedance state, increasing the current (through-current) consumption of the port. generally, the resistance of a pull-up or pull- down resistor is several 10 k w , though it depends on the application circuit. 2. the i/o ports are set in the general-purpose input port mode at power-on reset, when reset by the reset pin, or when reset due to overflow or underflow of the watchdog timer or the stack.
23 m pd17704, 17705, 17707, 17708, 17709 1.4 cautions on using ce, int0 through int4, and reset pins the ce, int0 through int4, and reset pins have a function to set a test mode in which the internal operations of the m pd17709 are tested (ic test), in addition to the functions listed in 1.1 pin function list. when a voltage exceeding v dd is applied to any of these pins, the device is set in the test mode. if a noise exceeding v dd is superimposed during normal operation, therefore, the test mode is set by mistake, hindering the normal operation. especially if the wiring length of pins is too long, noise is superimposed on these pins. in consequence, the above problem occurs. therefore, keep the wiring length as short as possible to prevent noise from being superimposed. if superimposition of noise is unavoidable, connect an external component as illustrated below to suppress the noise. ? connect a diode with low v f ? connect a capacitor between a pin and v dd . between a pin and v dd . 1.5 cautions on using test pin when v dd is applied to the test pin, the device is set in the test mode. therefore, be sure to keep the wiring length of this pin as short as possible, and directly connect it to the gnd pin. if the wiring length between the test pin and gnd pin is too long, or if external noise is superimposed on the test pin, generating a potential difference between the test pin and gnd pin, your program may not run normally. ce, int0-int4, reset v dd ce, int0-int4, reset v dd diode with low v f v dd v dd gnd test short
m pd17704, 17705, 17707, 17708, 17709 24 2. program memory (rom) 2.1 outline of program memory figure 2-1 outlines the program memory. as shown in this figure, the addresses of the program memory are specified by the program counter. the program memory has the following two major functions. ? to store programs ? to store constant data figure 2-1. outline of program memory instruction constant data program memory program counter address specification
25 m pd17704, 17705, 17707, 17708, 17709 2.2 program memory figure 2-2 shows the configuration of the program memory. as shown in this figure, the m pd17704 has 16k bytes (8192 16 bits) of program memory, the m pd17707 has 24k bytes (12288 16 bits), and the m pd17708 and 17709 have 32k bytes (16384 16 bits). therefore, the program memory addresses of the m pd17704 are 0000h through 1fffh, those of the m pd17705, 17707 are 0000h through 2fffh, and those of the m pd17708 and 17709 are 0000h through 3fffh. because all instructions are one-word instructions, one instruction can be stored to one address of the program memory. as constant data, the contents of the program memory are read to the data buffer by using a table reference instruction. figure 2-2. configuration of program memory ( pd17708, 17709) 16 bits h h br addr instruction branch address br @ar instruction branch address call @ar instruction subroutine entry address movt dbf, @ar instruction table reference address address h h h h h h h h h h h h h h h h h h ( pd17705, 17707) reset start address serial interface 1 interrupt vector serial interface 0 interrupt vector timer 3 interrupt vector timer 2 interrupt vector timer 1 interrupt vector timer 0 interrupt vector int4 pin interrupt vector int3 pin interrupt vector int2 pin interrupt vector int1 pin interrupt vector int0 pin interrupt vector falling edge interrupt vector of ce pin segment 0 page 0 page 1 page 2 page 3 page 0 page 1 page 2 page 3 call addr instruction subroutine entry address call addr instruction subroutine entry address br addr instruction branch address segment 1 (system segment) 0 f 1 2 3 4 5 6 7 8 9 a b c f f f f 0 f 0 f 0 0 0 0 0 0 0 0 0 0 0 0 f f f f 0 f 0 f 0 0 0 0 0 0 0 0 0 0 0 0 7 f 7 f 0 f 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 2 2 m m ( pd17704) m
m pd17704, 17705, 17707, 17708, 17709 26 2.3 program counter 2.3.1 configuration of program counter figure 2-3 shows the configuration of the program counter. as shown in this figure, the program counter consists of a 13-bit binary counter and a 1-bit segment register (sgr). bits 11 and 12 of the program counter indicate a page. the program counter specifies an address of the program memory. figure 2-3. configuration of program counter 2.3.2 segment register (sgr) the segment register specifies a segment of the program memory. table 2-1 shows the relationships between the segment register and program memory. the segment register is set only when the syscal entry instruction is executed. table 2-1. relationships between segment register and program memory value of segment register segment of program memory 0 segment 0 1 segment 1 2.4 flow of program the flow of the program is controlled by the program counter that specifies an address of the program memory. the program flow when each instruction is executed is described below. figure 2-5 shows the value that is set to the program counter when each instruction is executed. table 2-2 shows the vector address when an interrupt is accepted. 2.4.1 branch instruction (1) direct branch (br addr) the branch destination address of the direct branch instruction is in the same segment of the program memory. in other words, a branch cannot be executed exceeding a segment. (2) indirect branch (br @ar) the branch destination addresses of the indirect branch instruction are all the addresses of the program memory, i.e., addresses 0000h through 1fffh for the m pd17704, addresses 0000h through 2fffh for the m pd17705, 17707, and 0000h through 3fffh for the m pd17708 and 17709. for further information, also refer to 5.3 address register (ar) . pc 0 sgr page pc pc 12 pc 11 pc 10 pc 9 pc 8 pc 7 pc 6 pc 5 pc 4 pc 3 pc 2 pc 1
27 m pd17704, 17705, 17707, 17708, 17709 2.4.2 subroutine (1) direct subroutine call (call addr) the first address of a subroutine that can be called by the direct subroutine instruction is in page 0 of each segment (addresses 0000h through 07ffh). (2) indirect subroutine call (call @ar) the first addresses of a subroutine that can be called by the indirect subroutine call instruction are all the addresses of the program memory, i.e., addresses 000h through 1fffh for the m pd17704, addresses 0000h through 2fffh for the m pd17705, 17707, and 0000h through 3fffh for the m pd17708 and 17709. for further information, also refer to 5.3 address register (ar). 2.4.3 table reference the addresses that can be referenced by the table reference instruction (movt dbf, @ar) are all the addresses of the program memory, i.e., addresses 0000h through 1fffh for the m pd17704, addresses 0000h through 2fffh for the m pd17705, 17707, and 0000h through 3fffh for the m pd17708 and 17709. for further information, also refer to 5.3 address register (ar) and 9.2.2 table reference instruction (movt, dbf, @ar) . 2.4.4 system call the first address of a subroutine that can be called by the system call instruction (syscal entry) is the first 16 steps of each block (block 0 to 7) in page 0 of segment 1 (system segment). figure 2-4. outline of system call instruction page 1 page 2 page 3 page 0 (16 bits 2k steps) (16 bits 8k steps) segment 0 page 1 page 2 page 3 (16 bits 8k steps) segment 1 (system segment) block 0 block 1 block 2 block 7 block 0 of segment 1 entry address of syscal instruction 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 7 f 7 f 8 0 8 0 f f f f 0 0 0 0 f f f f 0 0 0 0 h h h h h h h h 0 0 0 0 0 0 0 0 2 2 3 3 2 3 3 2 7 f 7 f 8 0 8 0 f f f f 0 0 0 0 f f f f 0 0 0 0 h h h h h h h h 020ffh 02100h 021ffh 02200h 022ffh 02700h 02000h 0200fh area where entry address of system segment can be specified . . . .
m pd17704, 17705, 17707, 17708, 17709 28 figure 2-5. value of program counter upon execution of instruction table 2-2. interrupt vector address order internal/external interrupt source vector address 1 external falling edge of ce pin 00ch 2 external int0 pin 00bh 3 external int1 pin 00ah 4 external int2 pin 009h 5 external int3 pin 008h 6 external int4 pin 007h 7 internal timer 0 006h 8 internal timer 1 005h 9 internal timer 2 004h 10 internal timer 3 003h 11 internal serial interface 0 002h 12 internal serial interface 1 001h contents of program counter (pc) sgr 1 0 0 b 12 0 0 1 1 0 0 0 b 11 0 1 0 1 0 0 0 b 10 0 b 9 0 b 8 0 b 7 0 0 b 6 0 0 b 5 0 0 b 4 0 0 b 3 0 b 2 0 b 1 0 b 0 0 program counter instruction br addr call addr syscal entry br @ar call @ar movt dbf, @ar ret retsk reti other instructions (including skip instruction) when interrupt is accepted power-on reset, watchdog timer reset, reset pin, ce reset page 0 page 1 page 2 page 3 entry l entry h operand of instruction (addr) operand of instruction (addr) contents of address register re- tained re- tained contents of address stack register (asr) (return address) specified by stack pointer (sp) vector address of each interrupt increment entry h : high-order 3 bits of entry entry l : low-order 4 bits of entry re- tained
29 m pd17704, 17705, 17707, 17708, 17709 2.5 cautions on using program memory 2.5.1 last address in each segment the segment register is not connected to the binary counter. therefore, address 0000h of segment 0 is specified next to address 1fffh, which is the last address of segment 0. to specify between segments, a dedicated instruction such as an indirect branch, indirect subroutine call, or system call instruction is used.
m pd17704, 17705, 17707, 17708, 17709 30 3. address stack (ask) 3.1 outline of address stack figure 3-1 outlines the address stack. the address stack consists of a stack pointer and address stack registers. the address of an address stack register is specified by the stack pointer. the address stack saves a return address when a subroutine call instruction is executed or when an interrupt is accepted. the address stack is also used when the table reference instruction is executed. figure 3-1. outline of address stack 3.2 address stack register (asr) figure 3-2 shows the configuration of the address stack register. the address stack register consists of sixteen 16-bit registers asr0 through asr15. actually, however, it consists of fifteen 16-bit registers (asr0 through asr14) because no register is allocated to asr15. the address stack saves a return address when a subroutine is called, when an interrupt is accepted, and when the table reference instruction is executed. stack pointer return address address stack register address specification
31 m pd17704, 17705, 17707, 17708, 17709 figure 3-2. configuration of address stack register b 3 b 2 b 1 b 0 stack pointer (sp) b 3 sp3 b 2 sp2 b 1 sp1 b 0 sp0 b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 bit address stack register (asr) address 0h 1h 2h 3h 4h 5h 6h 7h 8h 9h ah bh ch dh eh fh asr0 asr1 asr2 asr3 asr4 asr5 asr6 asr7 asr8 asr9 asr10 asr11 asr12 asr13 asr14 asr15 (undefined) cannot be used bit
m pd17704, 17705, 17707, 17708, 17709 32 3.3 stack pointer (sp) 3.3.1 configuration and function of stack pointer figure 3-3 shows the configuration and functions of the stack pointer. the stack pointer consists of a 4-bit binary counter. it specifies the address of an address stack register. a value can be directly read from or written to the stack pointer by using a register manipulation instruction. figure 3-3. configuration and function of stack pointer retained power-on reset wdt&sp reset ce reset clock stop name flag symbol b 3 s p 3 b 2 s p 2 b 1 s p 1 b 0 s p 0 address 01h read/write r/w stack pointer (sp) 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 address 0 (asr0) address 1 (asr1) address 2 (asr2) address 3 (asr3) address 4 (asr4) address 5 (asr5) address 6 (asr6) address 7 (asr7) address 8 (asr8) address 9 (asr9) address 10 (asr10) address 11 (asr11) address 12 (asr12) address 13 (asr13) address 14 (asr14) setting prohibited specifies address of address stack register (asr) 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 ( at reset ( ( ( power-on reset wdt&sp reset ce reset clock stop : reset by reset pin up on power application : reset by watchdog timer and stack pointer : ce reset : upon execution of clock stop instruction ( ( ( (
33 m pd17704, 17705, 17707, 17708, 17709 3.4 operation of address stack 3.4.1 subroutine call instruction (call addr, call @ar) and return instruction (ret, retsk) when a subroutine call instruction is executed, the value of the stack pointer is decremented by one, and the return address is stored to an address stack register specified by the stack pointer. when the return instruction is executed, the contents of the address stack register (return address) specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.2 table reference instruction (movt dbf, @ar) when the table reference instruction is executed, the value of the stack pointer is incremented by one, and the return address is stored to an address stack register specified by the stack pointer. next, the contents of the program memory specified by the address register are read to the data buffer, the contents of the address stack register (return value) specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.3 when interrupt is accepted and on execution of return instruction (reti) when an interrupt is accepted, the value of the stack pointer is decremented by one, and the return address is stored to an address stack register specified by the stack pointer. when the return instruction is executed, the contents of an address stack register (return value) specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.4 address stack manipulation instruction (push ar, pop ar) when the push instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register are transferred to an address stack register specified by the stack pointer. when the pop instruction is executed, the contents of an address stack register specified by the stack pointer are transferred to the address register, and the value of the stack pointer is incremented by one. 3.4.5 system call instruction (syscal entry) and return instruction (ret, retsk) when the syscal entry instruction is executed, the value of the stack pointer is decremented by one, and the return address and the value of the segment register are stored to an address stack register specified by the stack pointer. when the return instruction is executed, the contents of an address stack register (return value) specified by the stack pointer are restored to the program counter and segment register, and the value of the stack pointer is incremented by one.
m pd17704, 17705, 17707, 17708, 17709 34 3.5 cautions on using address stack 3.5.1 nesting level and operation on overflow the value of address stack register (asr15) is undefined when the value of the stack pointer is 0fh. accordingly, if a subroutine call or system call exceeding 15 levels, or an interrupt is used without manipulating the stack, execution returns to an undefined address. 3.5.2 reset on detection of overflow or underflow of address stack whether the device is reset on detection of overflow or underflow of the address stack can be specified by program. at reset, the program is started from address 0, and some control registers are initialized. this reset function is valid at power-on reset or reset by the reset pin. for details, refer to 21. reset .
35 m pd17704, 17705, 17707, 17708, 17709 4. data memory (ram) 4.1 outline of data memory figure 4-1 outlines the data memory. as shown in the figure, system registers, a data buffer, port registers, and port input/output selection registers are located on the data memory. the data memory stores data, transfers data with the peripheral hardware or ports, and controls the cpu. figure 4-1. outline of data memory (1/3) (a) m pd17709 note port input/output selection registers are allocated to addresses 60h through 6fh of bank 15. peripheral hardware data transfer column address data memory bank0 port registers port registers port registers port registers bank1 bank2 bank3 bank4 bank14 bank15 note system registers ports 0123456789abcdef data transfer 0 1 2 3 4 5 6 7 data buffer ........ row address
m pd17704, 17705, 17707, 17708, 17709 36 figure 4-1. outline of data memory (2/3) (b) m pd17707, 17708 note port input/output selection registers are allocated to addresses 60h through 6fh of bank 15. cautions 1. the m pd17707 and 17708 do not have banks 10 through 14. 2. nothing is allocated to addresses 00h through 5fh of bank15. peripheral hardware data transfer column address data memory bank0 port registers port registers port registers port registers bank1 bank2 bank3 bank4 bank9 bank15 note system registers ports 0123456789abcdef data transfer 0 1 2 3 4 5 6 7 data buffer row address ........
37 m pd17704, 17705, 17707, 17708, 17709 figure 4-1. outline of data memory (3/3) (c) m pd17704, 17705 note port input/output selection registers are allocated to addresses 60h through 6fh of bank 15. cautions 1. the m pd17704 and 17705 do not have banks 6 through 14. 2. nothing is allocated to addresses 00h through 5fh of bank15. peripheral hardware data transfer column address data memory bank0 port registers port registers port registers port registers bank1 bank2 bank3 bank4 bank5 bank15 note system registers ports 0123456789abcdef data transfer 0 1 2 3 4 5 6 7 data buffer row address
m pd17704, 17705, 17707, 17708, 17709 38 4.2 configuration and function of data memory figure 4-2 shows the configuration of the data memory. as shown in this figure, the data memory is divided into several banks with each bank made up of a total of 128 nibbles with 7h row addresses and 0fh column addresses. the data memory can be divided into five functional blocks. each block is described in 4.2.1 through 4.2.5 below. the contents of the data memory can be operated on, compared, judged, and transferred in 4-bit units with a single data memory manipulation instruction. table 4-1 lists the data memory manipulation instructions. 4.2.1 system registers (sysreg) the system registers are allocated to addresses 74h through 7fh. because the system registers are allocated to all banks, the same system registers exist at addresses 74h through 7fh of any bank. for details, refer to 5. system register (sysreg) . 4.2.2 data buffer (dbf) the data buffer is allocated to addresses 0ch through 0fh of bank 0. for details, refer to 9. data buffer (dbf) . 4.2.3 port registers the port registers are allocated to addresses 70h through 73h of banks 0 through 3. for details, refer to 11. general-purpose ports . 4.2.4 port input/output selection registers port input/output selection registers are allocated to addresses 60h through 6fh of bank15. for details, refer to 8.4 port input/output selection register . 4.2.5 general-purpose data memory the general-purpose data memory is allocated to the addresses of the data memory excluding those of the system registers, port registers, and port input/output selection registers. (a) m pd17709 the general-purpose data memory of the m pd17709 consists of a total of 1776 nibbles of the 112 nibbles each of banks 0 through 15 (bank15 only has 96 nibbles). (b) m pd17707, 17708 the general-purpose data memory of the m pd17707 and 17708 consists of a total of 1120 nibbles of the 112 nibbles each of banks 0 through 9. (c) m pd17704, 17705 the general-purpose data memory of the m pd17704 and 17705 consists of a total of 672 nibbles of the 112 nibbles each of banks 0 through 5.
39 m pd17704, 17705, 17707, 17708, 17709 figure 4-2. configuration of data memory (1/3) (a) m pd17709 note an identical system register exists. system registers bank0 data memory 0 1 2 3 4 5 6 7 0 bank1 column address 01 0 1 2 3 4 5 6 7 general registers system registers (sysreg) note example address 51h of bank 0 b 3 b 2 b 1 b 0 0 1 2 3 4 5 6 7 port register system registers (sysreg) note 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 system registers (sysreg) note system registers (sysreg) note 123456789abcdef bank2 bank14 bank15 23456789ab c def data buffer 0123456789ab c def 0123456789ab c def fixed to 0 column address fixed to 0 0123456789ab c def bank0 column address bank1-bank3 column address bank4-bank14 column address bank15 port register port input/output selection registers row address row address row address row address row address
m pd17704, 17705, 17707, 17708, 17709 40 figure 4-2. configuration of data memory (2/3) (b) m pd17707, 17708 note an identical system register exists. cautions 1. the m pd17707 and 17708 do not have banks 10 through 14. 2. nothing is allocated to addresses 00h through 5fh of bank15. system registers bank0 data memory 0 1 2 3 4 5 6 7 0 bank1 column address 01 0 1 2 3 4 5 6 7 general registers system registers (sysreg) note example address 51h of bank 0 b 3 b 2 b 1 b 0 0 1 2 3 4 5 6 7 port register system registers (sysreg) note 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 system registers (sysreg) note system registers (sysreg) note 123456789abcdef bank2 bank9 bank15 23456789ab c def data buffer 0123456789ab c def 0123456789ab c def column address fixed to 0 0123456789ab c def bank0 column address bank1-bank3 column address bank4-bank9 column address bank15 port register fixed to 0 port input/output selection registers nothing is allocated row address row address row address row address row address
41 m pd17704, 17705, 17707, 17708, 17709 figure 4-2. configuration of data memory (3/3) (c) m pd17704, 17705 note an identical system register exists. cautions 1. the m pd17704 and 17705 do not have banks 6 through 14. 2. nothing is allocated to addresses 00h through 5fh of bank15. system registers bank0 data memory 0 1 2 3 4 5 6 7 0 bank1 column address 01 0 1 2 3 4 5 6 7 general registers system registers (sysreg) note example address 51h of bank 0 b 3 b 2 b 1 b 0 0 1 2 3 4 5 6 7 port register system registers (sysreg) note 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 system registers (sysreg) note system registers (sysreg) note 123456789abcdef bank2 bank5 bank15 23456789ab c def data buffer 0123456789ab c def 0123456789ab c def column address fixed to 0 0123456789ab c def bank0 column address bank1-bank3 column address bank4, bank5 column address bank15 port register fixed to 0 port input/output selection registers row address row address row address row address row address
m pd17704, 17705, 17707, 17708, 17709 42 table 4-1. data memory manipulation instructions function instruction operation add add addc subtract sub subc logic and or xor compare ske skge sklt skne transfer mov ld st judge skt skf 4.3 data memory addressing figure 4-3 shows address specification of the data memory. an address of the data memory is specified by a bank, row address, and column address. a row address and a column address are directly specified by a data memory manipulation instruction. however, a bank is specified by the contents of a bank register. for the details of the bank register, refer to 5. system register (sysreg) . figure 4-3. address specification of data memory data memory address bank register column address row address bank b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 instruction operand
43 m pd17704, 17705, 17707, 17708, 17709 4.4 cautions on using data memory 4.4.1 at power-on reset the contents of the general-purpose data memory are undefined at power-on reset. initialize the data memory as necessary. 4.4.2 cautions on data memory not provided if a data memory manipulation instruction that reads the data memory is executed to a data memory address not provided, undefined data is read. nothing is changed even if data is written to such an address.
m pd17704, 17705, 17707, 17708, 17709 44 5. system registers (sysreg) 5.1 outline of system registers figure 5-1 shows the location of the system registers on the data memory and their outline. as shown in the figure, the system registers are allocated to addresses 74h through 7fh of all the banks of the data memory. therefore, identical system registers exist at addresses 74h through 7fh of any bank. because the system registers are located on the data memory, they can be manipulated by all data memory manipulation instructions. seven types of system registers are available depending on function. figure 5-1. location and outline of system registers on data memory column address data memory bank0 bank1 bank2 0123456789abcdef 0 1 2 3 4 5 6 7 bank14 bank15 system register address name function 74h 75h 76h 77h 78h 79h 7ah 7bh 7ch 7dh 7eh 7fh address register (ar) controls program memory address window register (wr) transfers data with register file bank register (bank) specifies bank of data memory data memory row address pointer (mp) index register (ix) modifies address of data memory general register pointer (rp) specifies address of general register program status word (psword) controls operation row address ...... remark m the pd17704 and 17705 do not have the banks 6 through 14. the pd17707 and 17708 do not have banks 10 through 14. m
45 m pd17704, 17705, 17707, 17708, 17709 5.2 system register list figure 5-2 shows the configurations of the system registers. figure 5-2. configuration of system registers address name symbol bit data 74h 75h 76h 77h 78h 79h 7ah 7bh 7ch 7dh 7eh 7fh address register (ar) window register (wr) bank register (bank) data memory row address pointer (mp) index register (ix) general register pointer (rp) program status word (psword) system registers ar3 ar2 ar1 ar0 wr bank ixh mph ixm mpl ixl rph rpl psw b 2 b 1 b 0 b 3 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 m p e 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b c d b 3 b 2 b 1 b 0 c m p c y zi x e (rp) (ix) (mp)
m pd17704, 17705, 17707, 17708, 17709 46 5.3 address register (ar) 5.3.1 configuration of address register figure 5-3 shows the configuration of the address register. as shown in the figure, the address register consists of 16 bits of system register addresses 74h through 77h (ar3 through ar0). figure 5-3. configuration of address register address name symbol bit data 74h ar3 75h ar2 76h ar1 77h ar0 b 3 m s b b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 l s b power-on reset wdt&sp reset ce reset clock stop address register (ar) at reset 0 0 0 retained 0 0 0 retained 0 0 0 retained 0 0 0 retained power-on reset wdt&sp reset ce reset clock stop : reset by reset pin on power application : reset by watchdog timer and stack pointer : ce reset : on execution of clock stop instruction
47 m pd17704, 17705, 17707, 17708, 17709 5.3.2 function of address register the address register specifies a program memory address when the table reference instruction (movt dbf, @ar), stack manipulation instruction (push ar, pop ar), indirect branch instruction (br @ar), or indirect subroutine call instruction (call @ar) is executed. a dedicated instruction (inc ar) is available that can increment the contents of the address instruction by one. the following paragraphs (1) through (5) describe the operation of the address register when the respective instructions are executed. (1) table reference instruction (movt dbf, @ar) when the table reference instruction is executed, the constant data (16 bits) of a program memory address specified by the contents of the address register are read to the data buffer. the constant data that can be specified by the address register is stored to address 0000h to 1fffh in the case of m pd17704, address 0000h to 2fffh in the case of the m pd17705 and 17707, and address 0000h to 3fffh in the case of the m pd17708 and 17709. (2) stack manipulation instruction (push ar, pop ar) when the push ar instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register (ar) are transferred to an address stack register specified by the stack pointer whose value has been decremented by one. when the pop ar instruction is executed, the contents of an address stack register specified by the stack pointer are transferred to the address register, and the value of the stack pointer is incremented by one. (3) indirect branch instruction (br @ar) when this instruction is executed, the program branches to a program memory address specified by the contents of the address register. the branch address that can be specified by the address register is 0000h to 1fffh in the case of m pd17704, 0000h to 2fffh in the case of the m pd17705 and 17707, and 0000h to 3fffh in the case of the m pd17705 and 17708 and 17709. (4) indirect subroutine call instruction (call @ar) the subroutine at a program memory address specified by the contents of the address register can be called. the first address of the subroutine that can be specified by the address register is 0000h to 1fffh in the case of the m pd17704, 0000h to 2fffh in the case of the m pd17705 and 17707, and 0000h to 3fffh in the case of the m pd17708 and 17709. (5) address register increment instruction (inc ar) this instruction increments the contents of the address register by one. 5.3.3 address register and data buffer the address register can transfer data as part of the peripheral hardware via the data buffer. for details, refer to 9. data buffer (dbf) .
m pd17704, 17705, 17707, 17708, 17709 48 5.3.4 cautions on using address register because the address register is configured in 16 bits, it can specify an address up to ffffh. however, the program memory exists at addresses 0000h to 1fffh in the case of m pd17704, 0000h to 2fffh in the case of the m pd17705 and 17707 and 0000h to 3fffh in the case of the m pd17708 and 17709. therefore, the maximum value that can be set to the address register of the m pd17704 is address 1fffh. in the case of the m pd17705 and 17707, it is address 2fffh. in the case of the m pd17708 and 17709, it is address 3fffh. 5.4 window register (wr) 5.4.1 configuration of window register figure 5-4 shows the configuration of the window register. as shown in the figure, the window register consists of 4 bits of system register address 78h (wr). figure 5-4. configuration of window register 5.4.2 function of window register the window register is used to transfer data with the register file (rf) to be described later. data transfer between the window register and register file is manipulated by using dedicated instructions peek wr, rf and poke, rf wr (rf: address of register file). the following paragraphs (1) and (2) describe the operation of the window register when these instructions are executed. for further information, also refer to 8. register file (rf) . (1) peek wr, rf instruction when this instruction is executed, the contents of the register file addressed by rf are transferred to the window register. (2) poke rf, wr instruction when this instruction is executed, the contents of the window register are transferred to the register file addressed by rf. address name symbol bit data clock stop 78h window register (wr) wr undefined retained b 3 m s b b 2 b 1 b 0 l s b power-on reset wdt&sp reset ce reset at reset
49 m pd17704, 17705, 17707, 17708, 17709 5.5 bank register (bank) 5.5.1 configuration of bank register figure 5-5 shows the configuration of the bank register. as shown in the figure, the bank register consists of 4 bits of system register address 79h (bank). figure 5-5. configuration of bank register 5.5.2 function of bank register the bank register specifies a bank of the data memory. table 5-1 shows the relationships between the value of the bank register and a bank of the data memory that is specified. because the bank register is one of the system registers, its contents can be rewritten regardless of the bank currently specified. when manipulating a bank register, therefore, the status of the bank at that time is irrelevant. table 5-1. data memory bank specification note do not set banks 6 through 14 in the m pd17704 and 17705, and banks 10 through 14 in the m pd17707 and 17708 because these banks are not provided. caution the area to which the data memory is allocated differs depending on the model. for details, refer to figure 4-2 configuration of data memory. address name symbol bit data clock stop 79h bank register (bank) bank 0 0 0 retained b 3 m s b b 2 b 1 b 0 l s b power-on reset wdt&sp reset ce reset at reset bank register (bank) bank of data memory b 3 b 2 b 1 b 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 bank0 bank1 bank2 bank3 bank4 bank5 bank6 note bank7 note bank register (bank) bank of data memory b 3 b 2 b 1 b 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 bank8 note bank9 note bank10 note bank11 note bank12 note bank13 note bank14 note bank15
m pd17704, 17705, 17707, 17708, 17709 50 5.6 index register (ix) and data memory row address pointer (mp: memory pointer) 5.6.1 configuration of index register and data memory row address pointer figure 5-6 shows the configuration of the index register and data memory row address pointer. as shown in the figure, the index register consists of an index register (ix) made up of 11 bits (the low-order 3 bits (ixh) of system register address 7ah, and 7bh and 7ch (ixm, ixl)) and an index enable flag (ixe) at the lowest bit position of 7fh (psw). the data memory row address pointer (memory pointer) consists of a data memory row address pointer (mp) that is made up of 7 bits of the low-order 3 bits of 7ah (mph) and 7bh (mpl), and a data memory row address pointer enable flag (memory pointer enable flag: mpe) at the lowest bit position of 7ah (mph). in other words, the high-order 7 bits of the index register are shared with the data memory row address pointer figure 5-6. configuration of index register and data memory row address pointer address name symbol bit data clock stop 7ah ixh mph 0 0 0 retained 7bh index register (ix) ixm mpl 0 0 0 retained 7ch ixl 0 0 0 retained 7eh 7fh psw memory pointer (mp) b 3 m p e b 2 m s b m s b b 1 b 0 b 3 b 2 b 1 b 0 l s b b 3 b 2 b 1 b 0 l s b b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 i x e 0 0 0 r power-on reset wdt&sp reset ce reset ix program status word (psword) mp at reset r: retained
51 m pd17704, 17705, 17707, 17708, 17709 5.6.2 functions of index register and data memory row address pointer the index register and data memory row address pointer modify the addresses of the data memory. the following paragraphs (1) and (2) describe their functions. a dedicated instruction (inc ix) that increments the value of the index register by one is available. for the details of address modification, refer to 7. alu (arithmetic logic unit) block . (1) index register (ix) when a data memory manipulation instruction is executed, the data memory address is modified by the contents of the index register. this modification, however, is valid only when the ixe flag is set to 1. to modify the address, the bank, row address, and column address of the data memory are ored with the contents of the index register, and the instruction is executed to a data memory address (called real address) specified by the result of this or operation. all data memory manipulation instructions are subject to address modification by the index register. the following instructions, however, are not subject to address modification by the index register. inc ar rorc r inx ix call addr movt dbf, @ar call @ar push ar ret pop ar retsk peek wr,rf reti poke rf,wr ei get dbf,p di put p, dbf stop s br addr halt h br @ar nop (2) data memory row address pointer (mp) when the general register indirect transfer instruction (mov @r,m or mov m,@r) is executed, the indirect transfer destination address is modified. this modification, however, is valid only when the mpe flag is set to 1. to modify the address, the bank and row address at the indirect transfer destination are replaced by the contents of the data memory row address pointer. instructions other than the general register indirect transfer instruction are not subject to address modification. (3) index register increment instruction (inc ix) this instruction increments the contents of the index register by one. because the index register is configured of 10 bits, its contents are incremented to 000h if the inc ix instruction is executed when the contents of the index register are 3ffh.
m pd17704, 17705, 17707, 17708, 17709 52 5.7 general register pointer (rp) 5.7.1 configuration of general register pointer figure 5-7 shows the configuration of the general register pointer. as shown in the figure, the general register pointer consists of 7 bits including 4 bits of system register address 7dh (rph) and the high-order 3 bits of address 7eh (rpl). figure 5-7. configuration of general register pointer 7dh rph 0 0 0 retained 7eh rpl 0 0 0 retained b 3 m s b b 2 b 1 b 0 b 3 b 2 b 1 l s b b 0 b c d general register pointer (rp) address name symbol bit data clock stop power-on reset wdt&sp reset ce reset at reset
53 m pd17704, 17705, 17707, 17708, 17709 5.7.2 function of general register pointer the general register pointer specifies a general register on the data memory. figure 5-8 shows the addresses of the general registers specified by the general register pointer. as shown in the figure, a bank is specified by the high-order 4 bits (rph: address 7dh) of the general register pointer, and a row address is specified by the low-order 3 bits (rpl: address 7eh). because the valid number of bits of the general register pointer is 7, all the row addresses (0h through 7fh) of all the banks can be specified as general registers. for the details of the operation of the general register, refer to 6. general register (gr) . figure 5-8. address of general register specified by general register pointer remark the m pd17704 and 17705 do not have banks 6 through 14. the m pd17707 and 17708 do not have banks 10 through 14. caution the area to which the data memory is allocated differs depending on the model. for details, refer to figure 4-2 configuration of data memory. 5.7.3 cautions on using general register pointer the lowest bit of address 7eh (rpl) of the general register pointer is allocated as the bcd flag of the program status word. when rewriting rpl, therefore, pay attention to the value of the bcd flag. general register pointer (rp) rph rpl b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 specifies row address of each bank bank bank0 bank15 row address 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 specifies bank 0h 1h 2h 3h 4h 5h 6h 7h l s b b c d m s b
m pd17704, 17705, 17707, 17708, 17709 54 5.8 program status word (psword) 5.8.1 configuration of program status word figure 5-9 shows the configuration of the program status word. as shown in the figure, th program status word consists of a total of 5 bits including the lowest bit of system register address 7eh (rpl) and 4 bits of address 7fh (psw). each bit of the program status word has its own function. the 5 bits of the program status word are bcd flag (bcd), compare flag (cmp), carry flag (cy), zero flag (z), and index enable flag (ixe). figure 5-9. configuration of program status word 7eh rpl 0 0 0 retained 7fh psw 0 0 0 retained b 3 b 2 b 1 b 0 b c d b 3 c m p b 2 c y b 1 z b 0 i x e program status word (psword) address name symbol bit data clock stop power-on reset wdt&sp reset ce reset at reset
55 m pd17704, 17705, 17707, 17708, 17709 5.8.2 function of program status word the program status word is a register that sets the conditions under which the alu (arithmetic logic unit) executes an operation or data transfer, or indicates the result of an operation. table 5-2 outlines the function of each flag of the program status word. for details, refer to 7. alu (arithmetic logic unit) block . table 5-2. outline of function of each flag of program status word 5.8.3 cautions on using program status word when an arithmetic operation (addition or subtraction) is executed to the program status word, the result of the arithmetic operation is stored. for example, even if an operation that generates a carry is executed, if the result of the operation is 0000b, 0000b is stored to the psw. program status word (psword) rpl psw b 3 b 2 b 1 b 0 b c d b 3 c m p b 2 c y b 1 z b 0 i x e flag name index enable flag (ixe) zero flag (z) carry flag (cy) compare flag (cmp) bcd flag (bcd) function modifies address of data memory when data memory manipulation instruction is exeuted. 0 : does not modify 1 : modifies indicates result of arithmetic operation is zero. status of this flag differs depending on contents of compare flag. indicates occurrence of carry or borrow as result of execution of addition or subtraction instruction. this flag is reset to 0 if no carry or borrow occurs. it is set to 1 if carry or borrow occurs. this flag is also used as shift bit of rorc r instruction. indicates whether result of arithmetic operation is stored to data memory or general register. 0 : stores result. 1 : does not store result. indicates whether arithmetic operation is performed in decimal or binary. 0 : binary operation 1 : decimla operation (rp)
m pd17704, 17705, 17707, 17708, 17709 56 6. general register (gr) 6.1 outline of general register figure 6-1 outlines the general register. as shown in the figure, the general register is specified in the data memory by the general register pointer. the bank and row address of the general register are specified by the general register pointer. the general register is used to transfer or operate data between data memory addresses. figure 6-1. outline of general register remark the m pd17704 and 17705 do not have banks 6 through 14. the m pd17707 and 17708 do not have banks 10 through 14. 6.2 general register the general register consists of 16 nibbles (16 4 bis) of the same row address on the data memory. for the range of the banks and row addresses that can be specified by the general register pointer as a general register, refer to 5.7 general register pointer (rp) . the 16 nibbles of the same row address specified as a general register operate or transfer data with the data memory by a single instruction. in other words, operation or data transfer between data memory addresses can be executed by a single instruction. the general register can be controlled by the data memory manipulation instruction, like the other data memory areas. column address bank2 bank1 bank0 data memory general register transfer, operation general register pointer system register bank15 bank14 row address ??????
57 m pd17704, 17705, 17707, 17708, 17709 6.3 generating address of general register by each instruction the following sections 6.3.1 and 6.3.2 explain how the address of the general register is generated when each instruction is executed. for the details of the operation of each instruction, refer to 7. alu (arithmetic logic unit) block . 6.3.1 add (add r, m, addc r, m) , subtract (sub r, m, subc r, m) , logical operation (and r, m, or r, m, xor r, m), direct transfer (ld r, m, st m, r), and rotation (rorc r) instructions table 6-1 shows the address of the general register specified by operand r of an instruction. operand r of an instruction specifies only a column address. table 6-1. generating address of general register 6.3.2 indirect transfer (mov @r, m, mov m, @r) instruction table 6-2 shows a general register address specified by instruction operand r and an indirect transfer address specified by @r. table 6-2. generating address of general register 6.4 cautions on using general register 6.4.1 row address of general register because the row address of the general register is specified by the general register pointer, the currently specified bank may differ from the bank of the general register. 6.4.2 operation between general register and immediate data no instruction is available that executes an operation between the general register and immediate data. to execute an operation between the general register and immediate data, the general register must be treated as a data memory area. general register address column address row address bank b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 r contents of general register pointer general register address indirect transfer address column address row address bank b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 r contents of general register pointer contents of r same as data memory
m pd17704, 17705, 17707, 17708, 17709 58 7. alu (arithmetic logic unit) block 7.1 outline of alu block figure 7-1 outlines the alu block. as shown in the figure, the alu block consists of an alu, temporary registers a and b, program status word, decimal adjustment circuit, and memory address control circuit. the alu operates on, judges, compares, rotates, and transfers 4-bit data in the data memory. figure 7-1. outline of alu block data bus address control data memory index modification memory pointer temporary register a temporary register b program status word carry/borrow/zero detection/decimal/storage specification alu ? arithmetic operation ? logical operation ? bit judgment ? comparison ? rotation ? transfer decimal adjustment
59 m pd17704, 17705, 17707, 17708, 17709 7.2 configuration and function of each block 7.2.1 alu the alu performs arithmetic operation, logical operation, bit judgment, comparison, rotation, and transfer of 4-bit data according to instructions specified by the program. 7.2.2 temporay registers a and b temporary registers a and b temporarily store 4-bit data. these registers are automatically used when an instruction is executed, and cannot be controlled by program. 7.2.3 program status word the program status word controls the operation of and stores the status of the alu. for further information on the program status word, also refer to 5.8 program status word (psword) . 7.2.4 decimal adjustment circuit the decimal adjustment circuit converts the result of an arithmetic operation into a decimal number if the bcd flag of the program status word is set to 1 during arthmetic operations. 7.2.5 address control circuit the address control circuit specifies an address of the data memory. at this time, address modification by the index register and data memory row address pointer is also controlled. 7.3 alu processing instruction list table 7-1 lists the alu operations when each instruction is executed. table 7-2 shows how data memory addresses are modified by the index register and data memory row address pointer. table 7-3 shows decimal adjustment data when a decimal operation is performed.
m pd17704, 17705, 17707, 17708, 17709 60 table 7-1. list of alu processing instruction operations alu instruction difference in operation depending on program status word (psword) address modification function value of value of operation operation of operation of z flag index memory bcd flag cmp flag cy flag pointer add add r, m 0 0 stores result of set if carry or set if result of operation modifies does not m, #n4 binary operation borrow occurs; is 0000b; otherwise, reset modify addc r, m 0 1 does not store result otherwise, reset retains status if result of operation m, #n4 of binary operation is 0000b; otherwise, reset subtract sub r, m 1 0 stores result of set if result of operation m, #n4 decimal operation is 0000b; otherwise, reset subc r, m 1 1 does not store result retains status if result of operation m, #n4 of decimal operation is 0000b; otherwise, reset logical or r, m dont care dont care not affected retains previous retains previous status modifies does not operation m, #n4 (retained) (retained) status modify and r, m m, #n4 xor r, m m, #n4 judge skt m, #n dont care dont care not affected retains previous retains previous status modifies does not skf m, #n (retained) (reset) status modify compare ske m, #n4 dont care dont care not affected retains previous retains previous status modifies does not skne m, #n4 (retained) (retained) status modify skge m, #n4 sklt m, #n4 transfer ld r, m dont care dont care not affected retains previous retains previous status modifies does not st m, r (retained) (retained) status modify mov m, #n4 @r, m modifies m, @r rotate rorc r dont care dont care not affected value of b 0 of retains previous status does not does not (retained) (retained) general register modify modify
61 m pd17704, 17705, 17707, 17708, 17709 table 7-2. modification of data memory address and indirect transfer address by index register and data memory row address pointer bank : bank register ix : index register ixe : index enable flag ixh : bits 10 through 8 of index register ixm : bits 7 through 4 of index register ixl : bits 3 through 0 of index register m : data memory address indicated by m r , m c m r : data memory row address (high-order) m c : data memory column address (low-order) mp : data memory row address pointer mpe : memory pointer enable flag r : general register column address rp : general register pointer (x) : contents addressed by x x: direct address such as m and r b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 general register address specified by r data memory address specified by m indirect transfer address specified by @r bank row address column address bank row address column address bank row address column address rp r bank m bank m r (r) ditto mp (r) ditto bank m bank m r ix (r) or mp (r) ditto ditto ditto mpe 0 1 0 1 ixe 0 0 1 1 ixh, ixm logical or logical
m pd17704, 17705, 17707, 17708, 17709 62 table 7-3. decimal adjustment data operation hexadecimal addition decimal addition operation hexadecimal addition decimal addition result cy operation result cy operation result result cy operation result cy operation result 0 0 0000b 0 0000b 0 0 0000b 0 0000b 1 0 0001b 0 0001b 1 0 0001b 0 0001b 2 0 0010b 0 0010b 2 0 0010b 0 0010b 3 0 0011b 0 0011b 3 0 0011b 0 0011b 4 0 0100b 0 0100b 4 0 0100b 0 0100b 5 0 0101b 0 0101b 5 0 0101b 0 0101b 6 0 0110b 0 0110b 6 0 0110b 0 0110b 7 0 0111b 0 0111b 7 0 0111b 0 0111b 8 0 1000b 0 1000b 8 0 1000b 0 1000b 9 0 1001b 0 1001b 9 0 1001b 0 1001b 10 0 1010b 1 0000b 10 0 1010b 1 1100b 11 0 1011b 1 0001b 11 0 1011b 1 1101b 12 0 1100b 1 0010b 12 0 1100b 1 1110b 13 0 1101b 1 0011b 13 0 1101b 1 1111b 14 0 1110b 1 0100b 14 0 1110b 1 1100b 15 0 1111b 1 0101b 15 0 1111b 1 1101b 16 1 0000b 1 0110b C16 1 0000b 1 1110b 17 1 0001b 1 0111b C15 1 0001b 1 1111b 18 1 0010b 1 1000b C14 1 0010b 1 1100b 19 1 0011b 1 1001b C13 1 0011b 1 1101b 20 1 0100b 1 1110b C12 1 0100b 1 1110b 21 1 0101b 1 1111b C11 1 0101b 1 1111b 22 1 0110b 1 1100b C10 1 0110b 1 0000b 23 1 0111b 1 1101b C9 1 0111b 1 0001b 24 1 1000b 1 1110b C8 1 1000b 1 0010b 25 1 1001b 1 1111b C7 1 1001b 1 0011b 26 1 1010b 1 1100b C6 1 1010b 1 0100b 27 1 1011b 1 1101b C5 1 1011b 1 0101b 28 1 1100b 1 1010b C4 1 1100b 1 0110b 29 1 1101b 1 1011b C3 1 1101b 1 0111b 30 1 1110b 1 1100b C2 1 1110b 1 1000b 31 1 1111b 1 1101b C1 1 1111b 1 1001b remark decimal adjustment is not correctly carried out in the shaded area in the above table.
63 m pd17704, 17705, 17707, 17708, 17709 7.4 cautions on using alu 7.4.1 cautions on execution operation to program status word if an arithmetic operation is executed to the program status word, the result of the operation is stored to the program status word. the cy and z flags in the program status word are usually set or reset by the result of the arithmetic operation. if an arithmetic operation is executed to the program status word itself, the result of the operation is stored to the program status word, and consequently, it cannot be judged whether a carry or borrow occurs or whether the result of the operation is zero. if the cmp flag is set, however, the result of the operation is not stored to the program status word. therefore, the cy and z flags are set or reset normally. 7.4.2 cautions on executing decimal operation the decimal operation can be executed only when the result of the operation falls within the following ranges: (1) result of addition : 0 to 19 in decimal (2) result of subtraction: 0 to 9 or C10 to C1 in decimal if a decimal operation is executed exceeding or falling below the above ranges, the result is a value greater than 1010b (0ah).
m pd17704, 17705, 17707, 17708, 17709 64 8. register file (rf) 8.1 outline of register file figure 8-1 outlines the register file. as shown in the figure, the rgister file consists of the control registers existing on a space different from the data memory, and a portion overlapping the data memory. the control registers set conditions of the peripheral hardware units. the data on the register file can be read or written via window register. figure 8-1. outline of register file control register (on separate space from data memory) (same space as data memory) data manipulation via window register 0 1 2 3 4 5 6 7 system register window re g ister peripheral hardware register file row address
65 m pd17704, 17705, 17707, 17708, 17709 8.2 configuration and function of register file figure 8-2 shows the configuration of the register file and the relationships between the register file and data memory. the register file is assigned addresses in 4-bit units, like the data memory, and consists of a total of 128 nibbles with row addresses 0h through 7fh and column addresses 0h through 0fh. addresses 00h through 3fh are control registers that sets the conditions of the peripheral hardware units. addresses 40h through 7fh overlap the data memory. in other words, addresses 40h through 7fh of the register file are addresses 40h through 7fh of the currently-selected bank of data memory. because addresses 40h through 7fh of the register file overlap the same addresses of the data memory, these addresses of the register file can be manipulated in the same manner as the data memory, except that the addresses of the register file can also be manipulated by using register file manipulation instructions (peek wr, rf and poke rf, wr). note, however, that addresses 60h through 6fh of bank15 are assigned port input/output selection registers (for details refer to 8.4 port input/output selection registers ). figure 8-2. configuration of register file and relationship with data memory remark the m pd17704 and 17705 do not have banks 6 through 14. the m pd17707 and 17708 do not have banks 10 through 14. column address 0 1 2 3 4 5 6 7 01 234 56789abcdef system registers 0 1 2 3 control registers data memory bank0 bank1 bank2 bank14 register file bank15 port input/output selection registers row address ??????
m pd17704, 17705, 17707, 17708, 17709 66 8.2.1 register file manipulation instructions (peek wr, rf, poke rf, wr) data is read from or written to the register file via the window register of the system registers, by using the following instructions. (1) peek wr, rf reads data of the register file addressed by rf to the window register. (2) poke rf, wr writes the data of the window register to the register file addressed by rf. 8.3 control registers figure 8-3 shows the configuration of the control registers. as shown in the figure, the control registers consist of a total of 64 nibbles (64 4 bits) of addresses 00h through 3fh of the register file. of these 64 nibbles, however, only 53 nibbles are actually used. the remaining 11 nibbles are unused registers and prohibited from being written or read. each control register has an attribute of 1 nibble that identifies four types of registers: read/write (r/w), read- only (r), write-only (w), and read-and-reset (r&reset) registers. nothing is changed even if data is written to a read-only (r and r&reset) register. an undefined value is read if a write-only (w) register is read. among the 4-bit data in 1 nibble, the bit fixed to 0 is always 0 when it is read, and is also 0 when it is written. the 11 nibbles of unused registers are undefined when their contents are read, and nothing changes even when they are written. table 8-1 lists the peripheral hardware control functions of the control registers.
67 m pd17704, 17705, 17707, 17708, 17709 [memo]
m pd17704, 17705, 17707, 17708, 17709 68 figure 8-3. configuration of control registers (1/2) note ( ) indicates an address that is used when the assembler is used. ( ) ( ) s p 3 s p 2 ( ) s p 1 ( ) s p 0 00w d t c k 1 w d t c k 0 w d t r e s 00000 ( ) d b f s p 1 ( ) d b f s p 0 00 i s p r e s a s p r e s c e c n t 3 c e c n t 2 c e c n t 1 c e c n t 0 00m o v t s e l 1 m o v t s e l 0 p l l r f c k 3 p l l r f c k 2 p l l r f c k 1 p l l r f c k 0 000p l l u l 00b e e p 1 s e l b e e p 0 s e l b e e p 1 c k 1 b e e p 1 c k 0 b e e p 0 c k 1 b e e p 0 c k 0 000w d t c y 000b t m 0 c y p l l s c n f 0p l l m d 1 p l l m d 0 000i f c g o s t t i f c m d 1 i f c m d 0 i f c c k 1 i f c c k 0 00i f c s t r t i f c r e s 0a d c c h 2 a d c c h 1 a d c c h 0 0a d c m d a d c s t t a d c c m p 0p w m b i t 0p w m c k 0p w m 2 s e l p w m 1 s e l p w m 0 s e l 00f c g c h 1 f c g c h 0 000 i r q s i o 1 000 i r q s i o 0 000 i r q t m 3 000 i r q t m 2 01 234 5 67 r/w r/w w & reset r r/w r/w r/w read/ write r/w r/w r&reset r/w r/w r&reset r&reset read/ write r/w r r/w w r/w r/w r/w r/w read/ write r r/w r/w r/w r/w read/ write column address row address item name stack pointer watchdog timer clock selection watchdog timer counter reset data buffer stack pointer stack overflow/ underflow reset selection ce reset timer carry counter movt bit selection symbol name pll mode selection pll reference frequency selection pll unlock ff beep/general -purpose port pin function selection beep clock selection watchdog timer/stack pointer reset status detection basic timer 0 carry name fcg channel selection if counter gate status detection if counter mode selection if counter control a/d converter channel selection pwm clock selection pwm/general- purpose port pin function selection a/d converter mode selection symbol name serial interface 1 interrupt request timer 3 interrupt request serial interface 0 interrupt request symbol timer 2 interrupt request 0 1 2 3 (8) note (9) note (a) note (b) note symbol
69 m pd17704, 17705, 17707, 17708, 17709 figure 8-3. configuration of control register (2/2) s i o 0 i m d 1 s i o 0 i m d 0 000s i o 0 w s t t 0s b m d s i o 0 c k 1 s i o 0 c k 0 00 ( ) ( ) s i o 0 s f 8 s i o 0 s f 9 s b s t t s b b s y s b a c k s i o 0 n w t s i o 0 w r q 1 s i o 0 w r q 0 s i o 0 c h s b s i o 0 m s s i o 0 t x s i o 1 t s s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0 i e g 4 i n t 4 s e l i e g 3 i n t 3 s e l 0i e g 2 i e g 1 i e g 0 00b t m 0 c k 1 b t m 0 c k 0 t m 2 e n t m 2 r e s t m 2 c k 1 t m 2 c k 0 t m 1 e n t m 1 r e s t m 1 c k 1 t m 1 c k 0 t m 0 e n t m 0 r e s t m 0 c k 1 t m 0 c k 0 t m 0 o v f t m 0 g c e g t m 0 g o e g t m 0 m d i p s i o 1 i p s i o 0 i p t m 3 i p t m 2 i p t m 1 i p t m 0 i p 4 i p 3 i p 2 i p 1 i p 0 i p c e t m 3 s e l 0t m 3 e n t m 3 r e s 89abcdef r r r/w r/w r r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w system register interrupt stack pointer serial i/o0 wait status judgment serial i/o0 clock selection serial i/o0 interrupt mode selection serial i/o0 status detection serial i/o0 wait control serial i/o0 mode selection basic timer 0 clock selection interrupt edge selection 1 timer 3 control timer 2 counter clock selection timer 1 counter clock selection timer 0 counter clock selection timer 0 mode selection interrupt enable 2 interrupt enable 1 int2 pin interrupt request int0 pin interrupt request ce pin interrupt request 0 s y s r s p 2 s y s r s p 1 s y s r s p 0 ( ) serial i/o1 mode selection interrupt edge selection 2 interrupt enable 3 000 i n t 4 00 i r q 4 i n t 3 00 i r q 3 i n t 2 00 i r q 2 i n t 1 00 i r q 1 i n t 0 00 i r q 0 c e 0c e c n t s t t i r q c e 000i r q t m 1 r/w r/w r/w r/w r/w r/w r/w r i r q t m 0 r / w timer 1 interrupt request timer 0 interrupt request int4 pin interrupt request int3 pin interrupt request int1 pin interrupt request
m pd17704, 17705, 17707, 17708, 17709 70 table 8-1. peripheral hardware control functions of control registers (1/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset stack stack pointer 01h r/w (sp3) fff retained (sp2) (sp1) (sp0) interrupt stack 08h r 0 555 retained pointer of (sysrsp2) system register (sysrsp1) (sysrsp0) data buffer 04h r 0 fixed to 0 0 0 0 retained stack pointer 0 (dbfsp1) detects nesting level (dbfsp0) of data buffer stack stack overflow/ 05h r/w 0 fixed to 0 3 retained retained retained underflow reset 0 selection ispres selects interrupt stack reset reset valid overflow/underflow reset prohibited (can be set only once following power application) aspres selects address stack overflow/underflow reset (can be set only once following power application) watchdog watchdog timer 02h r/w 0 fixed to 0 3 retained retained retained timer clock selection 0 wdtck1 selects clock of watchdog timer (can be wdtck0 set only once following power application) watchdog timer 03h w & wdtres resets watchdog timer counter invalid reset if written undefined undefined undefined undefined counter reset reset 0 fixed to 0 0 0 wdt&sp reset 16h r & 0 01 retained retained status detection reset 0 0 wdtcy detects resetting of watchdog no reset reset request timer/stack pointer request b 3 b 2 b 1 b 0 0011 level 0 level 1 level 2 level 3 0101 00 1 1 not 65536 setting 131072 used instruction prohibited instruction 01 0 1
71 m pd17704, 17705, 17707, 17708, 17709 table 8-1. peripheral hardware control functions of control registers (2/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset ce ce reset timer 06h r/w cecnt3 sets number of ce reset timer 1 retained retained 1 carry counter cecnt2 carry counts cecnt1 cecnt0 movt bit 07h r/w 0 fixed to 0 0 0 0 retained selection 0 movtsel1 sets bit transferred by movt (transferred movtsel0 to dbf1, 0 during 8-bit transfer) serial serial i/o0 wait 0ah r 0 fixed to 0 0000 interface status judgment 0 0 sio0wstt judges wait status of serial during wait during serial interface 0 communication serial i/o0 0bh r/w 0 fixed to 0 0000 clock selection sbmd selects operation mode of i 2 c continues reception mode is bus during slave transmission processing set automatically sio0ck1 sets internal clck of serial sio0ck0 interface 0 serial i/o0 0ch r/w 0 fixed to 0 0000 interrupt mode 0 selection sio0imd1 sets interrupt condition of sio0imd0 serial interface 0 serial i/o0 0dh r sio0sf8 detects clock counter set at 8th clock 0000 status detection sio0sf9 set at 9th clock sbstt detects number of clocks set from start condition to (i 2 c bus mode) 9th clock sbbsy detects start condition set from start condition to (i 2 c bus mode) stop condition serial i/o0 wait 0eh r/w sback sets and detects acknowledge sets and detects 0, 1 0000 control (i 2 c bus mode) sio0nwt enables wait enabled cleared sio0wrq1 sets wait mode sio0wrq0 0: setting prohibited 1: 1 count 2: 2 counts 3: 3 counts 4: 4 counts 5: 5 counts 6: 6 counts 7: 7 counts 8: 8 counts 9: 9 counts a: 10 counts b: 11 counts c: 12 counts d: 13 counts e: 14 counts f: 15 coounts 00 0 1 16-bit high-order low-order transfer 8-bit transfer 8-bit transfer 01 1 0 0011 93.75 375 281.25 46.875 khz khz khz khz 0101 00 1 1 7th 8th 7th clock stop clock clock after start condition condition 01 0 1 00 1 1 no data acknowledge address wait wait wait wait 01 0 1 b 3 b 2 b 1 b 0
m pd17704, 17705, 17707, 17708, 17709 72 table 8-1. peripheral hardware control functions of control registers (3/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset serial serial i/o0 0fh r/w sio0ch selects serial i/o0 mode 0000 interface mode selection sb sio0ms sets master/slave slave operation master operation sio0tx sets transfer direction reception transmission serial i/o1 1dh r/w sio1ts starts or stops operation stops operation starts operation 0000 mode selection sio1hiz sets status of p0b1/so1 pin general-purpose serial data i/o port output pin sio1ck1 sets i/o clock sio1ck0 pll pll mode 10h r/w pllscnf sets low-order bits of swallow counter lowest bit is 0 lowest bit is 1 uurr frequency selection 0 fixed to 0 0000 synthesizer pllmd1 sets division mode of pll pllmd0 pll reference 11h r/w pllrfck3 sets reference frequency of pll ffff frequency pllrfck2 selection pllrfck1 pllrfck0 pll unlcok ff 12h r & 0 fixed to 0 undefined undefined retained retained reset 0 0 pllul detects status of unlock ff locked unclocked beep beep/general- 13h r/w 0 fixed to 0 0000 purpose port pin 0 function selection beep1sel selects function of p1d1/beep1 pin general-purpose beep beep0sel selects function of p1d0/beep0 pin i/o port beep clock 14h r/w beep1ck1 sets output frequency of beep1 0000 selection beep1ck0 beep0ck1 sets output frequency of beep0 beep0ck0 u: undefined r: retained 0011 not i 2 c 2-wire 3-wire used mode mode mode 0101 0: 1.25 khz 1: 2.5 khz 2: 5 khz 3: 10 khz 4: 6.25 khz 5: 12.5 khz 6: 25 khz 7: 50 khz 8: 3 khz 9: 9 khz a: 18 khz b: setting prohibited c: 1 khz d: 20 khz e: setting prohibited f: pll disabled 0 011 disabled mf vhf hf 0 101 0011 4 khz 3 khz 200 hz 67 hz 0101 0011 1 khz 3 khz 4 khz 6.7 khz 0101 0011 external 187.50 375.00 46.875 clock khz khz khz 0101 b 3 b 2 b 1 b 0
73 m pd17704, 17705, 17707, 17708, 17709 table 8-1. peripheral hardware control functions of control registers (4/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset timer basic timer 17h r & 0 fixed to 0 0 retained 1 retained 0 carry reset 0 0 btm0cy detects basic timer 0 carry ff ff reset ff set basic timer 0 18h r/w 0 fixed to 0 0 0 retained retained clock selection 0 btm0ck1 selects clock of basic timer 0 btm0ck0 timer 3 control 28h r/w tm3sel selects timer 3 and d/a converter d/a converter timer 3 0 0 retained 0 0 fixed to 0 tm3en starts or stops timer 3 counter stops starts tm3res resets timer 3 counter not affected reset timer 2 counter 29h r/w tm2en starts or stops timer 2 counter stops starts 0 0 retained 0 clock selection tm2res resets timer 2 counter not affected reset tm2ck1 sets basic clock of timer tm2ck0 2 counter timer 1 counter 2ah r/w tm1en starts or stops timer 1 counter stops starts 0 0 retained 0 clock selection tm1res resets timer 1 counter not affected reset tm1ck1 sets basic clock of timer tm1ck0 1 counter timer 0 counter 2bh r/w tm0en starts or stops timer 0 counter stops starts 0 0 retained 0 clock selection tm0res resets timer 0 counter not affected reset tm0ck1 sets basic clock of timer tm0ck0 0 counter timer 0 mode 2ch r/w tm0ovf detects timer 0 overflow no overflow overflow 0 0 retained 0 selection tm0gceg sets edge of gate close input rising edge falling edge signal tm0goeg sets edge of gate open input signal tm0md selects modulo counter/gate modulo counter gate counter counter of timer 0 0011 10 hz 20 hz 50 hz 100 hz 0101 0011 100 khz 10 khz 2 khz 1 khz 0101 0011 100 khz 10 khz 2 khz 1 khz 0101 0011 100 khz 10 khz 2 khz 1 khz 0101 b 3 b 2 b 1 b 0
m pd17704, 17705, 17707, 17708, 17709 74 table 8-1. peripheral hardware control functions of control registers (5/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset interrupt interrupt edge 1eh r/w ieg4 sets interrupt issuance edge rising edge falling edge 0 0 retained retained selection 1 (int4 pin) int4sel sets interrupt request flag of enables disables p1a3/int4 pin setting of flag setting of flag ieg3 sets interrupt issuance edge rising edge falling edge (int3 pin) int3sel sets interrupt request flag of enables disables p1a2/int3 pin setting of flag setting of flag interrupt edge 1fh r/w 0 fixed to 0 0 0 retained retained selection 2 ieg2 sets interrupt issuance edge rising edge falling edge (int2 pin) ieg1 sets interrupt issuance edge (int1 pin) ieg0 sets interrupt issuance edge (int0 pin) interrupt enable 1 2dh r/w ipsio1 enables serial interface 1 disables enables 0 0 retained retained interrupt interrupt interrupt ipsio0 enables serial interface 0 interrupt iptm3 enables timer 3 interrupt iptm2 enables timer 2 interrupt interrupt enable 2 2eh r/w iptm1 enables timer 1 interrupt disables enables 0 0 retained retained iptm0 enables timer 0 interrupt interrupt interrupt ip4 enables int4 pin interrupt ip3 enables int3 pin interrupt interrupt enable 3 2fh r/w ip2 enables int2 pin interrupt disables enables 0 0 retained retained ip1 enables int1 pin interrupt interrupt interrupt ip0 enables int0 pin interrupt ipce enables ce pin interrupt serial interface 1 34h r/w 0 fixed to 0 0 0 retained retained interrupt request 0 0 irqsio1 detects serial interface 1 no interrupt interrupt interrupt request request request b 3 b 2 b 1 b 0
75 m pd17704, 17705, 17707, 17708, 17709 table 8-1. peripheral hardware control functions of control registers (6/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset interrupt serial interface 0 35h r/w 0 fixed to 0 0 0 retained retained interrupt request 0 0 irqsio0 detects serial interface 0 no interrupt request interrupt request interrupt request timer 3 interrupt 36h r/w 0 fixed to 0 0 0 retained retained request 0 0 irqtm3 detects timer 3 interrupt request no interrupt request interrupt request timer 2 interrupt 37h r/w 0 fixed to 0 0 0 retained retained request 0 0 irqtm2 detects timer 2 interrupt request no interrupt request interrupt request timer 1 interrupt 38h r/w 0 fixed to 0 0 0 retained retained request 0 0 irqtm1 detects timer 1 interrupt request no interrupt request interrupt request timer 0 interrupt 39h r/w 0 fixed to 0 0 0 retained retained request 0 0 irqtm0 detects timer 0 interrupt request no interrupt request interrupt request int4 pin interrupt 3ah r/w int4 detects int4 pin status low level high level uuuu request 0 fixed to 0 0 0 retained retained 0 irq4 detects int4 pin interrupt request no interrupt request interrupt request int3 pin interrupt 3bh r/w int3 detects int3 pin status low level high level uuuu request 0 fixed to 0 0 0 retained retained 0 irq3 detects int3 pin interrupt request no interrupt request interrupt request int2 pin interrupt 3ch r/w int2 detects int2 pin status low level high level uuuu request 0 fixed to 0 0 0 retained retained 0 irq2 detects int2 pin interrupt request no interrupt request interrupt request int1 pin interrupt 3dh r/w int1 detects int1 pin status low level high level uuuu request 0 fixed to 0 0 0 retained retained 0 irq1 detects int1 pin interrupt request no interrupt request interrupt request u: undefined b 3 b 2 b 1 b 0
m pd17704, 17705, 17707, 17708, 17709 76 table 8-1. peripheral hardware control functions of control registers (7/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset interrupt int0 pin interrupt 3eh r/w int0 detects int0 pin status low level high level uuuu request 0 fixed to 0 0 0 retained retained 0 irq0 detects int0 pin interrupt request no interrupt request interrupt request ce pin interrupt 3fh r ce detects ce pin status low level high level uuuu request 0 fixed to 0 0000 cecntstt detects ce reset counter status stops operates r/w irqce detects ce pin interrupt request no interrupt request interrupt request 00rr if fcg channel 20h r/w 0 fixed to 0 0000 counter selection 0 fcgch1 sets pin to be used as fcg fcgch0 if counter gate 21h r 0 fixed to 0 0000 status detection 0 0 ifcgostt detects if counter gate status closed open if counter 22h r/w ifcmd1 sets if counter mode 0000 mode selection ifcmd0 ifcck1 sets if counter gate time and ifcck0 fcg count frequency if counter 23h w 0 fixed to 0 0000 control 0 ifcstrt starts or stops if counter nothing affected starts counter ifcres resets if counter data nothing affected starts counter a/d a/d converter 24h r/w 0 fixed to 0 0 0 retained retained converter channel adcch2 selects pin used for a/d converter selection adcch1 adcch0 a/d converter 25h r/w 0 fixed to 0 0000 mode selection adcmd selects comparison mode of software mode hardware mode retained retained a/d converter r adcstt detects operating status of conversion ends converting 0 0 a/d converter adccmp detects comparison result of v adcref > v adcin v adcref < v adcin 0 retained a/d converter u: undefined r: retained 0011 fcg fcg0 fcg1 setting not used pin pin prohibited 0101 0011 fcg amifc fmifc amifc2 0101 0011 1ms, 4 ms, 8 ms, open, 1 khz 100 khz 900 khz setting prohibited 0101 0: a/d converter not used 1: p0d0/ad0 pin 2: p0d1/ad1pin 3: p0d2/ad2 pin 4: p0d3/ad3 pin 5: p1c2/ad4 pin 6: p1c3/ad5 pin 7: setting prohibited b 3 b 2 b 1 b 0
77 m pd17704, 17705, 17707, 17708, 17709 table 8-1. peripheral hardware control functions of control registers (8/8) peripheral control register peripheral hardware control function at reset clock hardware name address read/ function set value power- wdt ce stop write symbol on & sp reset 01 reset reset d/a pwm clock 26h r/w 0 fixed to 0 0 0 retained 0 converter selection pwmbit selects number of bits of pwm 8 bits 9 bits counter 0 fixed to 0 pwmck selects output clock of timer 3 4.4 khz (8)/ 440 hz (8)/ 2.2 khz (9) 220 hz (9) pwm/general- 27h r/w 0 fixed to 0 0 0 retained 0 purpose port pin pwm2sel selects function of p1b2/pwm2 pin general-purpose d/a converter function selection pwm1sel selects function of p1b1/pwm1 pin output port pwm0sel selects function of p1b0/pwm0 pin b 3 b 2 b 1 b 0
m pd17704, 17705, 17707, 17708, 17709 78 8.4 port input/output selection registers figure 8-4 shows the configuration of the port input/output selection registers. as shown in this figure, the port input/output select registers consist of a total of 16 nibbles (16 4 bits) at addresses 60h through 6fh of bank 15 of the data memory. table 8-2 lists the control functions of the port input/output selection registers.
79 m pd17704, 17705, 17707, 17708, 17709 [memo]
m pd17704, 17705, 17707, 17708, 17709 80 figure 8-4. configuration of port input/output selection registers (1/2) (bank15) column address row address item 6 name symbol read/ write p 0 d p l d 3 p 0 d p l d 2 p 0 d p l d 1 p 0 d p l d 0 p 3 d g i o p 3 c g i o p 3 b g i o p 3 a g i o port 0d pull-down resistor selection group i/o selection 67 45 23 01 r/w r/w
81 m pd17704, 17705, 17707, 17708, 17709 figure 8-4. configuration of port input/output selection registers (2/2) p 0 b b i o 3 p 0 b b i o 2 p 0 b b i o 1 p 0 b b i o 0 p 0 a b i o 3 p 0 a b i o 2 p 0 a b i o 1 p 0 a b i o 0 port 0b bit i/o selection port 0a bit i/o selection ef cd ab 89 r/w r/w p 1 d b i o 3 p 1 d b i o 2 p 1 d b i o 1 p 1 d b i o 0 p 0 c b i o 3 p 0 c b i o 2 p 0 c b i o 1 p 0 c b i o 0 port 1d bit i/o selection port 0c bit i/o selection r/w r/w p 2 b b i o 3 p 2 b b i o 2 p 2 b b i o 1 p 2 b b i o 0 0p 2 a b i o 2 p 2 a b i o 1 p 2 a b i o 0 port 2b bit i/o selection port 2a bit i/o selection r/w r/w 0p 2 d b i o 2 p 2 d b i o 1 p 2 d b i o 0 p 2 c b i o 3 p 2 c b i o 2 p 2 c b i o 1 p 2 c b i o 0 port 2d bit i/o selection port 2c bit i/o selection r/w r/w
m pd17704, 17705, 17707, 17708, 17709 82 table 8-2. control functions of port input/output selection registers (1/2) peripheral port input/output selection register control function at reset clock hardware name address read/ function set value power- wdt ce stop (bank15) write symbol on & sp reset 01 reset reset input/ port 0d pull- 66h r/w p0dpld3 selects pull-down resistor of p0d3 pin pull-down pull-down 00 retained retained output down resistor p0dpld2 selects pull-down resistor of p0d2 pin resistor used resistor not used port selection p0dpld1 selects pull-down resistor of p0d1 pin p0dpld0 selects pull-down resistor of p0d0 pin group i/o 67h r/w p3dgio selects input/output of port 3d input output 0 0 retained retained selection p3cgio selects input/output of port 3c p3bgio selects input/output of port 3b p3agio selects input/output of port 3a port 2d bit i/o 68h r/w 0 fixed to 0 0 0 retained retained selection p2dbio2 selects input/output of port p2d2 input output p2dbio1 selects input/output of port p2d1 p2dbio0 selects input/output of port p2d0 port 2c bit i/o 69h r/w p2cbio3 selects input/output of port p2c3 input output 0 0 retained retained selection p2cbio2 selects input/output of port p2c2 p2cbio1 selects input/output of port p2c1 p2cbio0 selects input/output of port p2c0 port 2b bit i/o 6ah r/w p2bbio3 selects input/output of port p2b3 input output 0 0 retained retained selection p2bbio2 selects input/output of port p2b2 p2bbio1 selects input/output of port p2b1 p2bbio0 selects input/output of port p2b0 port 2a bit i/o 6bh r/w 0 fixed to 0 0 0 retained retained selection p2abio2 selects input/output of port p2a2 input output p2abio1 selects input/output of port p2a1 p2abio0 selects input/output of port p2a0 port 1d bit i/o 6ch r/w p1dbio3 selects input/output of port p1d3 input output 0 0 retained retained selection p1dbio2 selects input/output of port p1d2 p1dbio1 selects input/output of port p1d1 p1dbio0 selects input/output of port p1d0 port 0c bit i/o 6dh r/w p0cbio3 selects input/output of port p0c3 input output 0 0 retained retained selection p0cbio2 selects input/output of port p0c2 p0cbio1 selects input/output of port p0c1 p0cbio0 selects input/output of port p0c0 port 0b bit i/o 6eh r/w p0bbio3 selects input/output of port p0b3 input output 0 0 retained retained selection p0bbio2 selects input/output of port p0b2 p0bbio1 selects input/output of port p0b1 p0bbio0 selects input/output of port p0b0 b 3 b 2 b 1 b 0
83 m pd17704, 17705, 17707, 17708, 17709 table 8-2. control functions of port input/output selection registers (2/2) peripheral port input/output selection register control function at reset clock hardware name address read/ function set value power- wdt ce stop (bank15) write symbol on & sp reset 01 reset reset input/ port 0a bit i/o 6fh r/w p0abio3 selects input/output of port p0a3 input output 0 0 retained retained output selection p0abio2 selects input/output of port p0a2 port p0abio1 selects input/output of port p0a1 p0abio0 selects input/output of port p0a0 b 3 b 2 b 1 b 0
m pd17704, 17705, 17707, 17708, 17709 84 8.5 cautions on using register file keep in mind the following points (1) through (3) when using the write-only (w), read-only (r), and unused registers of the control registers (addresses 00h through 3fh of the register file). (1) an undefined value is read if a write-only register is read. (2) nothing is affected even if a read-only register is written. (3) an undefined value is read if an unused register is read. nor is anything affected if this register is written.
85 m pd17704, 17705, 17707, 17708, 17709 9. data buffer (dbf) 9.1 outline of data buffer figure 9-1 outlines the data buffer. the data buffer is located on the data memory and has the following two functions. ? reads constant data on the program memory (table reference) ? transfers data with the peripheral hardware units figure 9-1. outline of data buffr data buffer data write (put) data read (get) table reference (movt) peripheral hardware constant data program memory
m pd17704, 17705, 17707, 17708, 17709 86 9.2 data buffer 9.2.1 configuration of data buffer figure 9-2 shows the configuration of the data buffer. as shown in the figure, the data buffer consists of a total of 16 bits of addresses 0ch through 0fh of bank 0 on the data memory. the 16-bit data is configured with bit 3 of address 0ch as the msb and bit 0 of address 0fh as the lsb. because the data buffer is located on the data memory, it can be manipulated by all data memory manipulation instructions. figure 9-2. configuration of data buffer column address 0 1 2 3 4 5 6 7 0123456789abcdef bank0 bank1 bank2 bank14 bank15 system register address bit bit signal data b 3 b 15 b 2 b 14 b 1 b 13 b 0 b 12 dbf3 0ch b 3 b 11 b 2 b 10 b 1 b 9 b 0 b 8 dbf2 0dh b 3 b 7 b 2 b 6 b 1 b 5 b 0 b 4 dbf1 0eh b 3 b 3 b 2 b 2 b 1 b 1 b 0 b 0 dbf0 0fh data memory data buffer remark data buffer (dbf) row address data memory m s b ? l s b ? m data the pd17704 and 17705 do not have banks 6 through 14. the pd17707 and 17705 do not have banks 6 through 14. m
87 m pd17704, 17705, 17707, 17708, 17709 9.2.2 table reference instruction (movt dbf, @ar) this instruction moves the contents of the program memory addressed by the contents of the address register to the data buffer. the number of bits transferred by the table reference instruction can be specified by movt selection register (address 07h) of the control registers. when 8-bit data is transferred, it is read to dbf1 and 0. when the table reference instruction is used, one stack level is used. all the addresses of the program memory can be referenced by the table reference instruction. 9.2.3 peripheral hardware control instructions (put and get) the operations of the put and get instructions are as follows: (1) get dbf, p reads the data of a peripheral register addressed by p to the data buffer. (2) put p, dbf sets the data of the data buffer to a peripheral register addressed by p. 9.3 relationships between peripheral hardware and data buffer table 9-1 shows the relationships between the peripheral hardware and the data buffer.
m pd17704, 17705, 17707, 17708, 17709 88 table 9-1. relationships between peripheral hardware and data buffer (1/2) peripheral hardware peripheral register transferring data with data buffer name symbol peripheral execution of i/o actual address put/get bit bit instruction a/d converter a/d converter reference adcr 02h put/get 8 8 voltage setting register serial interface serial interface 0 presettable shift register 0 sio0sfr 03h put/get 8 8 serial interface 1 presettable shift register 1 sio1sfr 04h timer 0 timer 0 modulo register tm0m 1ah put/get 8 8 timer 0 counter tm0c 1bh get 8 8 timer 1 timer 1 modulo register tm1m 1ch put/get 8 8 timer 1 counter tm1c 1dh get 8 8 timer 2 timer 2 modulo register tm2m 1eh put/get 8 8 timer 2 counter tm2c 1fh get 8 8 address register address register ar 40h put/get 16 16 data buffer stack dbf stack dbfstk 41h put/get 16 16 pll frequency synthesizer note pll data register pllr 42h put/get 16 16 frequency counter if counter data register ifc 43h get 16 16 d/a converter p1b0/pwm0 pin pwm data register 0 pwmr0 44h put/get 16 9 (pwm output) p1b1/pwm1 pin pwm data register 1 pwmr1 45h p1b2/pwm2 pin pwm data register 2 pwmr2 46h put/get 16 9 timer 3 timer 3 modulo register tm3m 8 note the programmable counter of the pll frequency synthesizer is configured of 17 bits, of which the high- order 16 bits indicate the pll data register (pllr) and the low-order bits are allocated to the pllscnf flag (the third bit of address 10h). for details, refer to 17. pll frequency synthesizer .
89 m pd17704, 17705, 17707, 17708, 17709 table 9-1. relationships between peripheral hardware and data buffer (2/2) at reset clock function power-on wdt&sp ce stop reset reset reset 000 note 0 note sets compare voltage v adcref of a/d converter undefined undefined undefined undefined sets serial-out data and reads serial-in data ff ff retained ff sets modulo register value of timer 0 00 retained 0 reads count value of timer 0 counter ff ff retained ff sets modulo register value of timer 1 00 retained 0 reads count value of timer 1 counter ff ff retained ff sets modulo register value of timer 2 00 retained 0 reads count value of timer 2 counter 000 retained transfers data with address register undefined undefined retained retained saves data of data buffer undefined undefined retained retained sets division value (n value) of pll 0000 reads count value of frequency counter 1ff 1ff retained 1ff sets duty of output signal of d/a converter sets duty of output signal of d/a converter (multiplexed with modulo register of timer 3) sets modulo register value of timer 3 note value in hardare mode. retained in software mode.
m pd17704, 17705, 17707, 17708, 17709 90 9.4 cautions on using data buffer keep the following points in mind concerning the unused peripheral addresses, write-only peripheral register (put only), and read-only peripheral register (get only) when transferring data with the peripheral hardware via data buffer. ? an undefined value is read if a write-only register is read. ? nothing is affected even if a read-only register is written. ? an undefined value is read if an unused address is read. nor is anything affected if this address is written.
91 m pd17704, 17705, 17707, 17708, 17709 10. data buffer stack 10.1 outline of data buffer stack figure 10-1 outlines the data buffer stack. as shown in the figure, the data buffer stack consists of a data buffer stack pointer and data buffer stack registers. the data buffer stack saves or restores the contents of the data buffer when the put or get instruction is executed. therefore, the contents of the data buffer can be saved by one instruction when an interrupt is accepted. figure 10-1. outline of data buffer stack 10.2 data buffer stack register figure 10-2 shows the configuration of the data buffer stack registers. as shown in the figure, the data buffer stack registers consist of four 16-bit registers. the contents of the data buffer are saved by executing the put instruction, and the saved data is restored by executing the get instruction. the data buffer contents can be successively saved up to 4 levels. data buffer stack pointer dbf data buffer stack registers address specification
m pd17704, 17705, 17707, 17708, 17709 92 figure 10-2. configuration of data buffer stack register dbf3 dbf2 dbf1 dbf0 16 bits data buffer transfer data valid data b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 data buffer stack register dbfstk 41h get put saves contents of data buffer up to 4 levels bit name symbol address data
93 m pd17704, 17705, 17707, 17708, 17709 10.3 data buffer stack pointer the data buffer stack pointer detects the multiplexing level of the data buffer stack registers. when the put instruction is executed to the data buffer stack, the value of the data buffer stack pointer is incremented by one; when the get instruction is executed, the value of the pointer is decremented by one. the data buffer stack pointer can be only read and cannot be written. the configuration and function of the data buffer stack pointer are illustrated below. name flag symbol b 3 0 b 2 0 b 1 d b f s p 1 b 0 d b f s p 0 address 04h read/write r data buffer stack pointer power-on reset wdt&sp reset ce reset clock stop 0 1 0 1 level 0 level 1 level 2 level 3 detects multiplexing level of data buffer stack 0 0 1 1 retained fixed to 0 000 0 0 0 0 0 at reset
m pd17704, 17705, 17707, 17708, 17709 94 10.4 operation of data buffer stack figure 10-3 shows the operation of the data buffer stack. as shown in the figure, when the put instruction is executed, the contents of the data buffer are transferred to a data buffer stack register specified by the stack pointer, and the stack pointer is incremented by one. when the get instruction is executed, the contents of a data buffer stack register specified by the stack pointer are transferred to the data buffer, and the stack pointer is decremented by one. therefore, note that the value of the stack pointer is set to 1 if data has been written once because its initial value is 0, and that the stack pointer is set to 0 when data has been written four times. note that when writing (put) exceeding four levels, the first data are discarded. figure 10-3. operation of data buffer stack (a) if writing does not exceed level 4 (b) if writing exceeds level 4 undefined undefined undefined undefined v dd a undefined undefined undefined put a b undefined undefined put a b undefined undefined get a b undefined undefined get 0 1 2 3 a undefined undefined undefined put a b undefined undefined put a b c undefined put a b c d e b c d e b c d get e b c d get put put 0 1 2 3
95 m pd17704, 17705, 17707, 17708, 17709 10.5 using data buffer stack a program example is shown below. example to save the contents of the data buffer and address register by using int0 interrupt routine (the contents of the data buffer and address register are not automatically saved when an interrupt occurs). start: br initial ; reset address ; interrupt vector address nop ; si01 nop ; si00 nop ; tm3 nop ; tm2 nop ; tm1 nop ; tm0 nop ; int4 nop ; int3 nop ; int2 nop ; int1 br intint0 ; int0 nop ; down edge of ce intint0: put dbfstk, dbf ; saves contents of dbf to first level of data buffer ; stack (dbfstk) get dbf, ar ; transfers contents of address register (ar) to dbf put dbfstk, dbf ; saves contents of ar to second level of data buffer ; stack processing b ; int0 interrupt processing get dbf, dbfstk ; restores second level of data buffer stack to data buffer, put ar, dbf ; and restores contents of data buffer to address register get dbf, dbfstk ; restores first level of data buffer stack to data buffer ei reti initial: set1 ip0 ei loop: processing a br loop end 10.6 cautions on using data buffer stack the contents of the data buffer stack are not automatically saved when an interrupt is accepted, and therefore, must be saved by software. even when a bank of the data memory other than bank0 is specified, the contents of the data buffer (existing in bank0) can be saved or restored by using the put and get instructions.
m pd17704, 17705, 17707, 17708, 17709 96 11. general-purpose port the general-purpose ports output high-level, low-level, or floating signals to external circuits, and read high- level or low-level signals from external circuits. 11.1 outline of general-purpose port table 11-1 shows the relationships between each port and port register. the general-prupose ports are classified into i/o, input, and output ports. the i/o ports are further subclassified into bit i/o ports that can be set in the input or output mode in 1-bit (1-pin) units, and group i/o ports that can be set in the input or output mode in 4-bit (4-pin) units. the inut or output mode of each i/o port is specified by the port input/output selection registers (addresses 60h through 6fh) of bank15. table 11-1. relationships between port (pin) and port register (1/3) port pin data setting method no. symbol i/o port register (data memory) bank address symbol bit symbol (reserved word) port 0a 63 p0a3 i/o (bit i/o) bank0 70h p0a b 3 p0a3 64 p0a2 b 2 p0a2 65 p0a1 b 1 p0a1 66 p0a0 b 0 p0a0 port 0b 67 p0b3 i/o (bit i/o) 71h p0b b 3 p0b3 68 p0b2 b 2 p0b2 69 p0b1 b 1 p0b1 70 p0b0 b 0 p0b0 port 0c 59 p0c3 i/o (bit i/o) 72h p0c b 3 p0c3 60 p0c2 b 2 p0c2 61 p0c1 b 1 p0c1 62 p0c0 b 0 p0c0 port 0d 22 p0d3 input 73h p0d b 3 p0d3 23 p0d2 b 2 p0d2 24 p0d1 b 1 p0d1 25 p0d0 b 0 p0d0
97 m pd17704, 17705, 17707, 17708, 17709 table 11-1. relationships between port (pin) and port register (2/3) port pin data setting method no. symbol i/o port register (data memory) bank address symbol bit symbol (reserved word) port 1a 2 p1a3 input bank1 70h p1a b 3 p1a3 3 p1a2 b 2 p1a2 4 p1a1 b 1 p1a1 5 p1a0 b 0 p1a0 port 1b 17 p1b3 output 71h p1b b 3 p1b3 18 p1b2 b 2 p1b2 19 p1b1 b 1 p1b1 20 p1b0 b 0 p1b0 port 1c 26 p1c3 input 72h p1c b 3 p1c3 27 p1c2 b 2 p1c2 28 p1c1 b 1 p1c1 29 p1c0 b 0 p1c0 port 1d 37 p1d3 i/o (bit i/o) 73h p1d b 3 p1d3 38 p1d2 b 2 p1d2 39 p1d1 b 1 p1d1 40 p1d0 b 0 p1d0 port 2a no pin i/o (bit i/o) bank2 70h p2a b 3 C 14 p2a2 b 2 p2a2 15 p2a1 b 1 p2a1 16 p2a0 b 0 p2a0 port 2b 43 p2b3 i/o (bit i/o) 71h p2b b 3 p2b3 44 p2b2 b 2 p2b2 45 p2b1 b 1 p2b1 46 p2b0 b 0 p2b0 port 2c 55 p2c3 i/o 72h p2c b 3 p2c3 56 p2c2 (bit i/o) b 2 p2c2 57 p2c1 b 1 p2c1 58 p2c0 b 0 p2c0 port 2d no pin i/o (bit i/o) 73h p2d b 3 C 71 p2d2 b 2 p2d2 72 p2d1 b 1 p2d1 73 p2d0 b 0 p2d0
m pd17704, 17705, 17707, 17708, 17709 98 table 11-1. relationships between port (pin) and port register (3/3) port pin data setting method no. symbol i/o port register (data memory) bank address symbol bit symbol (reserved word) port 3a 6 p3a3 i/o bank3 70h p3a b 3 p3a3 7 p3a2 (group i/o) b 2 p3a2 8 p3a1 b 1 p3a1 9 p3a0 b 0 p3a0 port 3b 10 p3b3 i/o 71h p3b b 3 p3b3 11 p3b2 (group i/o) b 2 p3b2 12 p3b1 b 1 p3b1 13 p3b0 b 0 p3b0 port 3c 47 p3c3 i/o 72h p3c b 3 p3c3 48 p3c2 (group i/o) b 2 p3c2 49 p3c1 b 1 p3c1 50 p3c0 b 0 p3c0 port 3d 51 p3d3 i/o 73h p3d b 3 p3d3 52 p3d2 (group i/o) b 2 p3d2 53 p3d1 b 1 p3d1 54 p3d0 b 0 p3d0 C no pin C bank4 70h-73h C fixed to 0 | bank15 note note the m pd17704 and 17705 do not have banks 6 through 14. m pd17707 and 17708 do not have banks 10 through 14.
99 m pd17704, 17705, 17707, 17708, 17709 11.2 general-purpose i/o port (p0a, p0b, p0c, p1d, p2a, p2b, p2c, p2d, p3a, p3b, p3c, p3d) 11.2.1 configuration of i/o port the following paragraphs (1) and (2) show the configuration of the i/o ports. (1) p0a (p0a1, p0a0) p0b (p0b3, p0b2, p0b1, p0b0) p0c (p0c3, p0c2, p0c1, p0c0) p1d (p1d3, p1d2, p1d1, p1d0) p2a (p2a2, p2a1, p2a0) p2b (p2b3, p2b2, p2b1, p2b0) p2c (p2c3, p2c2, p2c1, p2c0) p2d (p2d2, p2d1, p2d0) p3a (p3a3, p3a2, p3a1, p3a0) p3b (p3b3, p3b2, p3b1, p3b0) p3c (p3c3, p3c2, p3c1, p3c0) p3d (p3d3, p3d2, p3d1, p3d0) note this is an internal signal that is output when the clock stop instruction is executed, and this circuit is designed not to increase the current consumption due to noise even if it is floated. v dd v dd i/o selection flag output latch 1 0 read instruction port register (1 bit) write instruction ckstop note
m pd17704, 17705, 17707, 17708, 17709 100 (2) p0a (p0a3, p0a2) note this is an internal signal that is output when the clock stop instruction is executed, and this circuit is designed not to increase the current consumption due to noise even if it is floated. 11.2.2 using i/o port the input or output mode of the i/o ports is set by i/o selection register p0a, p0b, p0c, p1d, p2a, p2b, p2c, p2d, p3a, p3b, p3c, or p3d of the control registers. because p0a, p0b, p0c, p1d, p2a, p2b, p2c, and p2d are bit i/o ports, they can be set in the input or output mode in 1-bit units. p3a, p3b, p3c, and p3d are group i/o ports, and therefore they are set in the input or output mode in 4- bit units. setting the output data of or reading the input data of a port is carried out by executing an instruction that writes data to or reads data from the port. 11.2.3 shows the configuration of the i/o selection register of each port. 11.2.4 and 11.2.5 describe how each port is used as an input or output port. 11.2.6 describes the points to be noted when using the i/o ports. v dd i/o selection flag output latch read instruction port register (1 bit) write instruction ckstop note
101 m pd17704, 17705, 17707, 17708, 17709 11.2.3 i/o port i/o selection register the following i/o selection registers of the i/o ports are available. ? port 0a bit i/o selection register ? port 0b bit i/o selection register ? port 0c bit i/o selection register ? port 1d bit i/o selection register ? port 2a bit i/o selection register ? port 2b bit i/o selection register ? port 2c bit i/o selection register ? port 2d bit i/o selection register ? group i/o selection registers (port 3a, port 3b, port 3c, port 3d) each i/o selection register sets the input or output mode of the corresponding port pin. the following paragraphs (1) through (9) descibe the configuration and functions of the above i/o selection registers.
m pd17704, 17705, 17707, 17708, 17709 102 (1) port 0a bit i/o selection register name flag symbol b 3 p 0 a b i o 3 b 2 p 0 a b i o 2 b 1 p 0 a b i o 1 b 0 p 0 a b i o 0 address (bank15) 6fh read/write r/w port 0a bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p0a0 pin in input mode sets p0a0 pin in output mode sets input/output mode of port retained retained sets p0a1 pin in input mode sets p0a1 pin in output mode sets input/output mode of port 0 1 sets p0a2 pin in input mode sets p0a2 pin in output mode sets input/output mode of port 0 1 sets p0a3 pin in input mode sets p0a3 pin in output mode sets input/output mode of port 0 1 0 0 0 0 0 0 0 0 at reset
103 m pd17704, 17705, 17707, 17708, 17709 (2) port 0b bit i/o selection register name flag symbol b 3 p 0 b b i o 3 b 2 p 0 b b i o 2 b 1 p 0 b b i o 1 b 0 p 0 b b i o 0 address (bank15) 6eh read/write r/w port 0b bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p0b0 pin in input mode sets p0b0 pin in output mode sets input/output mode of port retained retained sets p0b1 pin in input mode sets p0b1 pin in output mode sets input/output mode of port 0 1 sets p0b2 pin in input mode sets p0b2 pin in output mode sets input/output mode of port 0 1 sets p0b3 pin in input mode sets p0b3 pin in output mode sets input/output mode of port 0 1 0 0 0 0 0 0 0 0 at reset
m pd17704, 17705, 17707, 17708, 17709 104 (3) port 0c bit i/o selection register name flag symbol b 3 p 0 c b i o 3 b 2 p 0 c b i o 2 b 1 p 0 c b i o 1 b 0 p 0 c b i o 0 address (bank15) 6dh read/write r/w port 0c bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p0c0 pin in input mode sets p0c0 pin in output mode sets input/output mode of port retained retained sets p0c1 pin in input mode sets p0c1 pin in output mode sets input/output mode of port 0 1 sets p0c2 pin in input mode sets p0c2 pin in output mode sets input/output mode of port 0 1 sets p0c3 pin in input mode sets p0c3 pin in output mode sets input/output mode of port 0 1 0 0 0 0 0 0 0 0 at reset
105 m pd17704, 17705, 17707, 17708, 17709 (4) port 1d bit i/o selection register name flag symbol b 3 p 1 d b i o 3 b 2 p 1 d b i o 2 b 1 p 1 d b i o 1 b 0 p 1 d b i o 0 address (bank15) 6ch read/write r/w port 1d bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p1d0 pin in input mode sets p1d0 pin in output mode sets input/output mode of port retained retained sets p1d1 pin in input mode sets p1d1 pin in output mode sets input/output mode of port 0 1 sets p1d2 pin in input mode sets p1d2 pin in output mode sets input/output mode of port 0 1 sets p1d3 pin in input mode sets p1d3 pin in output mode sets input/output mode of port 0 1 0 0 0 0 0 0 0 0 at reset
m pd17704, 17705, 17707, 17708, 17709 106 (5) port 2a bit i/o selection register name flag symbol b 3 0 b 2 p 2 a b i o 2 b 1 p 2 a b i o 1 b 0 p 2 a b i o 0 address (bank15) 6bh read/write r/w port 2a bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p2a0 pin in input mode sets p2a0 pin in output mode sets input/output mode of port retained retained sets p2a1 pin in input mode sets p2a1 pin in output mode sets input/output mode of port 0 1 sets p2a2 pin in input mode sets p2a2 pin in output mode sets input/output mode of port 0 1 fixed to 0 0 0 0 0 0 0 0 at reset
107 m pd17704, 17705, 17707, 17708, 17709 (6) port 2b bit i/o selection register name flag symbol b 3 p 2 b b i o 3 b 2 p 2 b b i o 2 b 1 p 2 b b i o 1 b 0 p 2 b b i o 0 address (bank15) 6ah read/write r/w port 2b bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p2b0 pin in input mode sets p2b0 pin in output mode sets input/output mode of port retained retained sets p2b1 pin in input mode sets p2b1 pin in output mode sets input/output mode of port 0 1 sets p2b2 pin in input mode sets p2b2 pin in output mode sets input/output mode of port 0 1 sets p2b3 pin in input mode sets p2b3 pin in output mode sets input/output mode of port 0 1 0 0 0 0 0 0 0 0 at reset
m pd17704, 17705, 17707, 17708, 17709 108 (7) port 2c bit i/o selection register name flag symbol b 3 p 2 c b i o 3 b 2 p 2 c b i o 2 b 1 p 2 c b i o 1 b 0 p 2 c b i o 0 address (bank15) 69h read/write r/w port 2c bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p2c0 pin in input mode sets p2c0 pin in output mode sets input/output mode of port retained retained sets p2c1 pin in input mode sets p2c1 pin in output mode sets input/output mode of port 0 1 sets p2c2 pin in input mode sets p2c2 pin in output mode sets input/output mode of port 0 1 sets p2c3 pin in input mode sets p2c3 pin in output mode sets input/output mode of port 0 1 0 0 0 0 0 0 0 0 at reset
109 m pd17704, 17705, 17707, 17708, 17709 (8) port 2d bit i/o selection register name flag symbol b 3 0 b 2 p 2 d b i o 2 b 1 p 2 d b i o 1 b 0 p 2 d b i o 0 address (bank15) 68h read/write r/w port 2d bit i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p2d0 pin in input mode sets p2d0 pin in output mode sets input/output mode of port retained retained sets p2d1 pin in input mode sets p2d1 pin in output mode sets input/output mode of port 0 1 sets p2d2 pin in input mode sets p2d2 pin in output mode sets input/output mode of port 0 1 fixed to 0 0 0 0 0 0 0 0 at reset
m pd17704, 17705, 17707, 17708, 17709 110 (9) group i/o selection register (ports 3a, 3b, 3c, 3d) name flag symbol b 3 p 3 d g i o b 2 p 3 c g i o b 1 p 3 b g i o b 0 p 3 a g i o address (bank15) 67h read/write r/w group i/o selection power-on reset wdt&sp reset ce reset clock stop 0 1 sets p3a0 through p3a3 pins in input mode sets p3a0 through p3a3 pins in output mode sets input/output mode of port retained retained sets p3b0 through p3b3 pins in input mode sets p3b0 through p3b3 pins in output mode sets input/output mode of port 0 1 sets p3c0 through p3c3 pins in input mode sets p3c0 through p3c3 pins in output mode sets input/output mode of port 0 1 sets p3d0 through p3d3 pins in input mode sets p3d0 through p3d3 pins in output mode sets input/output mode of port 0 1 0 0 0 0 0 0 0 0 at reset
111 m pd17704, 17705, 17707, 17708, 17709 11.2.4 when using i/o port as input port the port pin to be set in the input mode is selected by the i/o selection register corresponding to the port. ports p0a, p0b, p0c, p1d, p2a, p2b, p2c, and p2d can be set in the input or output mode in 1-bit units. p3a, p3b, p3c, and p3d can be set in the input or output mode in 4-bit units. the pin set in the input mode is floated (hi-z) and waits for input of an external signal. the input data is read by executing a read instruction (such as skt) to the port register corresponding to the port pin. 1 is read from the port register when a high level is input to the corresponding port pin; when a low level is input to the port pin, 0 is read from the register. when a write instruction (such as mov) is executed to the port register corresponding to the pin set in the input mode, the contents of the output latch are rewritten. 11.2.5 when using i/o port as output port the port pin to be set in the output mode is selected by the i/o selection register corresponding to the port. ports p0a, p0b, p0c, p1d, p2a, p2b, p2c, and p2d can be set in the input or output mode in 1-bit units. p3a, p3b, p3c, and p3d can be set in the input or output mode in 4-bit units. the pin set in the output mode outputs the contents of the output latch. the output data is set by executing a write instruction (such as mov) to the port register corresponding to the port pin. write 1 to the port register to output a high level to the port pin; write 0 to output a low level. the port pin can be also floated (hi-z) if it is set in the input mode. if a read instruction (such as skt) is executed to the port register corresponding to a port pin set in the output mode, the contents of the output latch are read. note, however, that the contents of the output latch of the p0a3 and p0a2 pins may differ from the read contents because the status of these pins are read as are (refer to 11.2.6 ). 11.2.6 cautions on using i/o port (p0a3 and p0a2 pins) when using the p0a3 and p0a2 pins in the output mode, the contents of the output latch may be rewritten as shown in the example below. example to set the p0a3 and p0a2 pins in the output mode bank15 initflg p0abi03, p0abi02, not p0abi01, not p0abi00 ; sets p0a3 and p0a2 pins in output mode initflg p0a3, p0a2, not p0a1, not p0a0 ; outputs high level to p0a3 and p0a2 pins ; <1> clr1 p0a3 ; outputs low level to p0a3 pin macro extend and .mf.p0a3 shr 4, #.df.(not p0a3 and 0fh) if the p0a2 pin is externally made low when the instruction in the above example <1> is executed, the contents of the output latch of the p0a2 pin are rewritten to 0 by the clr1 instruction. in other words, if an instruction that reads the contents of port register p0a is executed while the p0a3 or p0a2 pin is set in the output mode, the contents of the output latch are rewritten to the pin level at that time, regardless of the previous status.
m pd17704, 17705, 17707, 17708, 17709 112 11.2.7 status of i/o port at reset (1) at power-on reset all the i/o ports are set in the input mode. the contents of the output latch are reset to 0. (2) at wdt&sp reset all the i/o ports are set in the input mode. the contents of the output latch are reset to 0. (3) at ce reset the setting of the input or output mode is retained. the contents of the output latch are also retained. (4) on execution of clock stop instruction the setting of the input or output mode is retained. the contents of the output latch are also retained. (5) in halt status the previous status is retained.
113 m pd17704, 17705, 17707, 17708, 17709 11.3 general-purpose input port (p0d, p1a, p1c) 11.3.1 configuration of input port the following paragraphs (1) and (2) show the configuration of the input port. (1) p0d (p0d3, p0d2, p0d1, p0d0) note this is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (2) p1a (p1a3, p1a2, p1a1, p1a0) p1c (p1c3, p1c2, p1c1, p1c0) note this is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (except p1a3, p1a2, p1a0) v dd write instruction read instruction port register (1 bit) ckstop note p0dpld flag high-on resistance input latch to a/d converter v dd to frequency counter or a/d converter write instruction read instruction port register (1 bit) ckstop note
m pd17704, 17705, 17707, 17708, 17709 114 11.3.2 using input port the input data is read by executing a read instruction (such as skt) to the port register corresponding to the port pin. 1 is read from the port register when a high level is input to the corresponding port pin; when a low level is input to the port pin, 0 is read from the register. nothing is affected even if a write instruction (such as mov) is executed to the port register. p0d has a pull-down resistor that can be connected or disconnected by software in 1-bit units. the pull-down resistor is connected when 0 is written to the corresponding bit of the port 0d pull-down resistor selection register. when 1 is written to the corresponding bit of this register, the pull-down resistor is disconnected. 11.3.3 port 0d pull-down resistor selection register the port 0d pull-down resistor selection register specifies whether a pull-down resistor is connected to p0d3 through p0d0 pins. the configuration and function of this register are illustrated below. ? port 0d pull-down resistor selection register name flag symbol b 3 p 0 d p l d 3 b 2 p 0 d p l d 2 b 1 p 0 d p l d 1 b 0 p 0 d p l d 0 address (bank15) 66h read/write r/w port 0d pull-down resistor selection power-on reset wdt&sp reset ce reset clock stop 0 1 connects pull-down resistor to p0d0 pin disconnects pull-down resistor from p0d0 pin selects pull-down resistor of p0d0 pin retained retained connects pull-down resistor to p0d1 pin disconnects pull-down resistor from p0d1 pin selects pull-down resistor of p0d1 pin 0 1 connects pull-down resistor to p0d2 pin disconnects pull-down resistor from p0d2 pin selects pull-down resistor of p0d2 pin 0 1 connects pull-down resistor to p0d3 pin disconnects pull-down resistor from p0d3 pin selects pull-down resistor of p0d3 pin 0 1 0 0 0 0 0 0 0 0 at reset
115 m pd17704, 17705, 17707, 17708, 17709 11.3.4 status of input port at reset (1) at power-on reset all the input ports are set in the input mode. all the pull-down resistors of p0d are connected. (2) at wdt&sp reset all the input ports are set in the input mode. all the pull-down resistors of p0d are connected. (3) at ce reset the input ports are set in the input mode. the pull-down resistors of p0d retain the previous status. (4) on execution of clock stop instruction the input ports are set in the input mode. the pull-down resistors of p0d retain the previous status. (5) in halt status the previous status is retained.
m pd17704, 17705, 17707, 17708, 17709 116 11.4 general-purpose output port (p1b) 11.4.1 configuration of output port the configuration of the output port is shown below. (1) p1b (p1b3, p1b2, p1b1, p1b0) 11.4.2 using output port the output port outputs the contents of the output latch to each pin. the output data is set by executing a write instruction (such as mov) to the port register corresponding to the port pin. write 1 to the port register to output a high level to the port pin; write 0 to output a low level. however, because p1b is an n-ch open-drain output port, it is floated when it outputs a high level. therefore, an external pull-up resistor must be connected to this port. if a read instruction (such as skt) is executed to the port register, the contents of the output latch are read. 11.4.3 status of output port at reset (1) at power-on reset the contents of the output latch are output. the contents of the output latch are reset to 0. (2) at wdt&sp reset the contents of the output latch are output. the contents of the output latch are reset to 0. (3) at ce reset the contents of the output latch are output. the contents of the output latch are retained. (4) on execution of clock stop instruction the contents of the output latch are output. the contents of the output latch are retained. (5) in halt status the contents of the output latch are output. the contents of the output latch are retained. output latch read instruction port register (1 bit) write instruction
117 m pd17704, 17705, 17707, 17708, 17709 12. interrupt 12.1 outline of interrupt block figure 12-1 outlines the interrupt block. as shown in the figure, the interrupt block temporarily stops the currently executed program and branches execution to a vector address in response to an interrupt request output by a peripheral hardware unit. the interrupt block consists of an interrupt request servicing block corresponding to each peripheral hardware unit, interrupt enable flip-flop that enables all interrupts, stack pointer that is controlled when an interrupt is accepted, address stack registers, program counter, and interrupt stack. the interrupt control block of each peripheral hardware unit consists of an interrupt request flag (irq ) that detects the corresponding interrupt request, interrupt enable flag (ip ) that enables the interrupt, and vector address generator (vag) that specifies a vector address when the interrupt is accepted. the m pd17709 has the following 12 types of maskable interrupts. ? ce pin falling edge interrupt ? int0 through int4 interrupts ? timer 0 through timer 3 interrupts ? serial interface 0 and serial interface 1 interrupts when an interrupt is accepted, execution branches to a predetermined address, and the interrupt is serviced.
m pd17704, 17705, 17707, 17708, 17709 118 figure 12-1. outline of interrupt block serial interface 1 ipsio1 flag serial interface 0 ipsio0 flag timer 3 iptm3 flag timer 2 iptm2 flag timer 1 iptm1 flag timer 0 iptm0 flag int4 pin ip4 flag int3 pin ip3 flag int2 pin ip2 flag int1 pin ip1 flag int0 pin ip0 flag ce pin falling ipce flag program counter address stack registers stack pointer interrupt stack pointer interrupt control block interrupt enable flip-flop di, ei instruction irqsio1 flag irqsio0 flag irqtm3 flag irqtm2 flag irqtm1 flag irqtm0 flag irqint4 flag irqint3 flag irqint2 flag irqint1 flag irqint0 flag irqce flag vector address generator 01h vector address generator 02h vector address generator 03h vector address generator 04h vector address generator 05h vector address generator 06h vector address generator 07h vector address generator 08h vector address generator 09h vector address generator 0ah vector address generator 0bh vector address generator 0ch system registers
119 m pd17704, 17705, 17707, 17708, 17709 12.2 interrupt control block an interrupt control block is provided for each peripheral hardware unit. this block detects issuance of an interrupt request, enables the interrupt, and generates a vector address when the interrupt is accepted. 12.2.1 configuration and function of interrupt request flag (irq ) each interrupt request flag is set to 1 when an interrupt request is issued by the corresponding peripheral hardware unit, and is reset to 0 when the interrupt is accepted. writing the interrupt request flag to 1 via a window register is equivalent to issuance of the interrupt request. by detecting the interrupt request flag when an interrupt is not enabled, issuance status of each interrupt request can be detected. once the interrupt request flag has been set, it is not reset until the corresponding interrupt is accepted, or until 0 is written to the flag via a window register. even if two or more interrupt requests are issued at the same time, the interrupt request flag corresponding to the interrupt that has not been accepted is not reset. figures 12-2 through 12-13 show the configuration and function of the respective interrupt request registers. figure 12-2. configuration of serial interface 1 interrupt request register name flag symbol b 3 0 b 2 0 b 1 0 b 0 i r q s i o 1 address 34h read/write r/w serial interface 1 interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of serial interface 1 fixed to 0 0 0 r r 0 0 0 r: retained at reset
m pd17704, 17705, 17707, 17708, 17709 120 figure 12-3. configuration of serial interface 0 interrupt request register figure 12-4. configuration of timer 3 interrupt request register name flag symbol b 3 0 b 2 0 b 1 0 b 0 i r q s i o 0 address 35h read/write r/w serial interface 0 interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of serial interface 0 fixed to 0 0 0 r r 0 0 0 r: retained at reset name flag symbol b 3 0 b 2 0 b 1 0 b 0 i r q t m 3 address 36h read/write r/w timer 3 interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of timer 3 fixed to 0 0 0 r r 0 0 0 r: retained at reset
121 m pd17704, 17705, 17707, 17708, 17709 figure 12-5. configuration of timer 2 interrupt request register figure 12-6. configuration of timer 1 interrupt request register name flag symbol b 3 0 b 2 0 b 1 0 b 0 i r q t m 1 address 38h read/write r/w timer 1 interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of timer 1 fixed to 0 0 0 r r 0 0 0 r: retained at reset name flag symbol b 3 0 b 2 0 b 1 0 b 0 i r q t m 2 address 37h read/write r/w timer 2 interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of timer 2 fixed to 0 0 0 r r 0 0 0 r: retained at reset
m pd17704, 17705, 17707, 17708, 17709 122 figure 12-7. configuration of timer 0 interrupt request register name flag symbol b 3 0 b 2 0 b 1 0 b 0 i r q t m 0 address 39h read/write r/w timer 0 interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of timer 0 fixed to 0 0 0 r r 0 0 0 r: retained at reset
123 m pd17704, 17705, 17707, 17708, 17709 figure 12-8. configuration of int4 pin interrupt request register name flag symbol b 3 i n t 4 b 2 0 b 1 0 b 0 i r q 4 address 3ah read/write r/w int4 pin interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of int4 pin fixed to 0 low level is input high level is input detects status of int4 pin 0 1 0 0 r r 0 0 u u u u u: undefined, r : retained at reset
m pd17704, 17705, 17707, 17708, 17709 124 figure 12-9. configuration of int3 pin interrupt request register name flag symbol b 3 i n t 3 b 2 0 b 1 0 b 0 i r q 3 address 3bh read/write r/w int3 pin interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of int3 pin fixed to 0 low level is input high level is input detects status of int3 pin 0 1 0 0 r r 0 0 u u u u u: undefined, r : retained at reset
125 m pd17704, 17705, 17707, 17708, 17709 figure 12-10. configuration of int2 pin interrupt request register name flag symbol b 3 i n t 2 b 2 0 b 1 0 b 0 i r q 2 address 3ch read/write r/w int2 pin interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of int2 pin fixed to 0 low level is input high level is input detects status of int2 pin 0 1 0 0 r r 0 0 u u u u u: undefined, r : retained at reset
m pd17704, 17705, 17707, 17708, 17709 126 figure 12-11. configuration of int1 pin interrupt request register name flag symbol b 3 i n t 1 b 2 0 b 1 0 b 0 i r q 1 address 3dh read/write r/w int1 pin interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of int1 pin fixed to 0 low level is input high level is input detects status of int1 pin 0 1 0 0 r r 0 0 u u u u u: undefined, r: retained at reset
127 m pd17704, 17705, 17707, 17708, 17709 figure 12-12. configuration of int0 pin interrupt request register name flag symbol b 3 i n t 0 b 2 0 b 1 0 b 0 i r q 0 address 3eh read/write r/w int0 pin interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of int0 pin fixed to 0 low level is input high level is input detects status of int0 pin 0 1 0 0 r r 0 0 u u u u u: undefined, r: retained at reset
m pd17704, 17705, 17707, 17708, 17709 128 figure 12-13. configuration of ce pin interrupt request register name flag symbol b 3 c e b 2 0 b 1 c e c n t s t t b 0 i r q c e address 3fh read/write r/w ce pin interrupt request power-on reset wdt&sp reset ce reset clock stop 0 1 u u u u 00 0 0 0 0 0 r r 0 1 interrupt request not issued interrupt request issued indicates interrupt request issuance status of ce pin stops operates detects status of ce reset counter fixed to 0 low level is input high level is input detects status of ce pin 0 1 u : undefined, r : retained at reset
129 m pd17704, 17705, 17707, 17708, 17709 12.2.2 function and configuration of interrupt request flag (ip ) each interrupt request flag enables the interrupt of the corresponding peripheral hardware unit. in order for an interrupt to be accepted, all the following conditions must be satisfied. ? the interrupt must be enabled by the corresponding interrupt request flag. ? the interrupt request must be issued by the corresponding interrupt request flag. ? the ei instruction (which enables all interrupts) must be executed. the interrupt enable flags are located on the interrupt enable register on the register file. figures 12-14 through 12-16 show the configuration and function of each interrupt enable register. figure 12-14. configuration of interrupt enable register 1 name flag symbol b 3 i p s i o 1 b 2 i p s i o 0 b 1 i p t m 3 b 0 i p t m 2 address 2dh read/write r/w interrupt enable 1 power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 0 0 0 0 0 0 0 0 1 disables enables enables or disables timer 2 interrupt disables enables enables or disables timer 3 interrupt disables enables enables or disables serial interface 0 interrupt disables enables enables or disables serial interface 1 interrupt 0 1 0 1 retained retained
m pd17704, 17705, 17707, 17708, 17709 130 figure 12-15. configuration of interrupt enable register 2 name flag symbol b 3 i p t m 1 b 2 i p t m 0 b 1 i p 4 b 0 i p 3 address 2eh read/write r/w interrupt enable 2 power-on reset wdt&sp reset ce reset at reset 0 1 0 0 0 0 0 0 0 0 0 1 disables enables enables or disables int3 pin interrupt enables or disables int4 pin interrupt enables or disables timer 0 interrupt enables or disables timer 1 interrupt 0 1 0 1 retained retained clock stop disables enables disables enables disables enables
131 m pd17704, 17705, 17707, 17708, 17709 figure 12-16. configuration of interrupt enable register 3 name flag symbol b 3 i p 2 b 2 i p 1 b 1 i p 0 b 0 i p c e address 2fh read/write r/w interrupt enable 3 at reset 0 1 0 0 0 0 0 0 0 0 0 1 enables or disables ce pin interrupt enables or disables int0 pin interrupt enables or disables int1 pin interrupt enables or disables int2 pin interrupt 0 1 0 1 power-on reset wdt&sp reset ce reset disables enables retained retained clock stop disables enables disables enables disables enables
m pd17704, 17705, 17707, 17708, 17709 132 12.2.3 vector address generator (vag) the vector address generator generates a branch address (vector address) of the program memory corresponding to an interrupt source that has been accepted from the corresponding peripheral hardware. table 12-1 shows the vector addresses of the respective interrupt sources. table 12-1. interrupt sources and vector addresses interrupt source vector address falling edge of ce pin 00ch int0 pin 00bh int1 pin 00ah int2 pin 009h int3 pin 008h int4 pin 007h timer 0 006h timer 1 005h timer 2 004h timer 3 003h serial interface 0 002h serial interface 1 001h
133 m pd17704, 17705, 17707, 17708, 17709 12.3 interrupt stack register 12.3.1 configuration and function of interrupt stack register figure 12-17 shows the configuration of the interrupt stack register. the interrupt stack register saves the contents of the following system registers (except the address register (ar)) when an interrupt is accepted. ? window register (wr) ? bank register (bank) ? index register (ix) ? general pointer (rp) ? program status word (psword) when an interrupt is accepted and the contents of the above system registers are saved to the interrupt stack, the contents of the above system registers, except the window register, are reset to 0. the interrupt stack can save the contents of the above system registers at up to four levels. therefore, interrupts can be nested up to four levels. the contents of the interrupt stack register are restored to the system registers when the interrupt return (reti) instruction is executed. the contents of the interrupt stack register are undefined at power-on reset. the previous contents are retained at ce reset and on execution of the clock stop instruction. figure 12-17. configuration of interrupt stack register window stack wrsk b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 bank stack banksk index stack h ixhsk index stack m ixhsk index stack l ixhsk pointer stack h rphsk pointer stack l rplsk status stack pswsk bit undefined interrupt stack register (intsk) name address 0h 1h 2h 3h 4h 5h intsk1 intsk2 intsk3 intsk4 interrupt stack pointer of system register bit b 2 b 3 b 0 b 1 s y s s p 2 0s y s s p 0 s y s s p 1 undefined
m pd17704, 17705, 17707, 17708, 17709 134 12.3.2 interrupt stack pointer of system register the interrupt stack pointer of the system register detects the nesting level of interrupts. the interrupt stack pointer can be only read and cannot be written. the configuration and function of the interrupt stack pointer are illustrated below. name flag symbol b 3 0 b 2 s y s r s p 2 b 1 s y s r s p 1 b 0 s y s r s p 0 address 08h read/write r interrupt stack pointer of system registers 01 1 1 0 0 0 1 1 1 use prohibited 4 levels (intsk1) 3 levels (intsk2) 2 levels (intsk3) 1 level (intsk4) 0 level detects level of interrupt stack of system registers fixed to 0 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 1 power-on reset wdt&sp reset ce reset retained at reset clock stop ( ) ( ) ( )
135 m pd17704, 17705, 17707, 17708, 17709 12.3.3 interrupt stack operation figure 12-8 shows the operation of the interrupt stack. when nested interrupts exceeding four levels are accepted, since the contents saved first are discarded they therefore must be saved by the program. figure 12-18. operation of interrupt stack (1/2) (a) where interrupt nesting level is 4 or less undefined undefined undefined undefined main undefined undefined undefined undefined main undefined undefined undefined a main undefined undefined undefined a main undefined undefined b a main undefined undefined main routine interrupt a interrupt b reti reti
m pd17704, 17705, 17707, 17708, 17709 136 figure 12-18. operation of interrupt stack (2/2) (b) where interrupt nesting level is 5 or more caution the system is reset when an interrupt of level 5 is accepted. however, the ispres flag, which resets the non-maskable interrupt if the interrupt stack overflows or underflows, must be set to 1. this flag is 1 after system reset, and can then be written only once. undefined undefined main main undefined undefined undefined a a main undefined undefined b main routine interrupt level 1 interrupt level 2 c b a main d d c b a e interrupt d interrupt e interrupt level 4 interrupt level 5 s y stem reset interrupt a interrupt c
137 m pd17704, 17705, 17707, 17708, 17709 12.4 stack pointer, address stack registers, and program counter the address stack registers save a return address when execution returns from an interrupt routine. the stack pointer specifies the address of an address stack register. when an interrupt is accepted, the value of the stack pointer is decremented by one, and the value of the program counter at that time is saved to an address stack register specified by the stack pointer. next, the interrupt routine is executed. when the interrupt return (reti) instruction is executed after that, the contents of an address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. for further information, also refer to 3. address stack (ask) . 12.5 interrupt enable flip-flop (inte) the interrupt enable flip-flop enables or disables the 12 types of maskable interrupts. when this flip-flop is set, all the interrupts are enabled. when it is reset, all the interrupts are disabled. this flip-flop is set or reset by dedicated instructions ei (to set) and di (to reset). the ei instruction sets this flip-flop when the instruction next to ei is executed, and the di instruction resets the flip-flop while it is being executed. when an interrupt is accepted, this flip-flop is automatically reset. this flip-flop is also reset at power-on reset, at a reset by the reset pin, at a watchdog timer, overflow or underflow of the stack, and at ce reset. the flip-flop retains the previous status on execution of the clock stop instruction.
m pd17704, 17705, 17707, 17708, 17709 138 12.6 accepting interrupt 12.6.1 accepting interrupt and priority the following operations are performed before an interrupt is accepted. (1) each peripheral hardware unit outputs an interrupt request signal to the corresponding interrupt request block if a given interrupt condition (for example, input of the falling signal to the int0 pin) is satisfied. (2) when each interrupt request block accepts an interrupt request signal from the corresponding peripheral hardware unit, it sets the corresponding interrupt request flag (for example, irq0 flag if it is the int0 pin that has issued the interrupt request) to 1. (3) the interrupt enable flag corresponding to each interrupt request flag (for example, ip0 flag if the interrupt request flag is irq0) is set to 1 when each interrupt request flag is set to 1, and each interrupt request block outputs 1. (4) the signal output by the interrupt request block is ored with the output of the interrupt enable flip-flop, and an interrupt accept signal is output. this interrupt enable flip-flop is set to 1 by the ei instruction, and reset to 0 by the di instruction. if 1 is output by each interrupt request processing block while the interrupt enable flip-flop is set to 1, the interrupt is accepted. as shown in figure 12-1, the output of the interrupt enable flip-flop is input to each interrupt request block via an and circuit when an interrupt is accepted. the signal input to each interrupt request block causes the interrupt request flag corresponding to each interrupt request flag to be reset to 0 and the vector address corresponding to each interrupt to be output. if the interrupt request block outputs 1 at this time, the interrupt accept signal is not transferred to the next stage. if two or more interrupt requests are issued at the same time, therefore, the interrupts are accepted according to the priority shown in table 12-2. unless the interrupt request enable flag is set to 1, the corresponding interrupt is not accepted. therefore, by resetting the interrupt enable flag to 0, the interrupt with a high hardware priority can be disabled. table 12-2. interrupt priority interrupt source priority falling edge of ce pin 1 int0 pin 2 int1 pin 3 int2 pin 4 int3 pin 5 int4 pin 6 timer 0 7 timer 1 8 timer 2 9 timer 3 10 serial interface 0 11 serial interface 1 12
139 m pd17704, 17705, 17707, 17708, 17709 12.6.2 timing chart when interrupt is accepted the timing charts in figure 12-19 illustrate the operations performed when an interrupt or interrupts are accepted. figure 12-19 (1) is the timing chart when one interrupt is accepted. (a) in (1) is the timing chart where the interrupt request flag is set to 1 after all the others, and (b) is the timing chart where the interrupt enable flag is set to 1 after all the others. in either case, the interrupt is accepted when the interrupt request flag, interrupt enable-flip flop, and interrupt enable flag all have been set to 1. if the flag or flip-flop that has been set last is set in the first instruction cycle of the movt dbf, @ar instruction or by an instruction that satisfies a given skip condition, the interrupt is accepted in the second instruction cycle of the movt dbf, @ar instruction or after the instruction that is skipped (this instruction is treated as nop) has been executed. the interrupt enable flip-flop is set in the instruction cycle next to that in which the ei instruction is executed. therefore, the interrupt is accepted after the instruction next to the ei instruction has been executed even when the interrupt request flag is set in the execution cycle of the ei instruction. (2) in figure 12-19 is the timing chart where two or more interrupts are used. when two or more interrupts are used, the interrupts are accepted according to the hardware priority if all the interrupt enable flags are set. however, the hardware priority can be changed by setting the interrupt enable flags by the program. instruction cycle shown in figure 12-19 is a special cycle in which the interrupt request flag is reset, a vector address is specified, and the contents of the program counter are saved after an interrupt has been accepted. it takes 1.78 m s, which is equivalent to one instruction execution time, to be completed. for details, refer to 12.7 operation after interrupt has been accepted .
m pd17704, 17705, 17707, 17708, 17709 140 figure 12-19. timing charts when interrupt is accepted (1/3) (1) when one interrupt (e.g., rising of int0 pin) is used (a) if there is no interrupt mask time by the interrupt flag (ip ) <1> if a normal instruction which is not movt or an instruction that satisfies a skip condition is executed when interrupt is accepted <2> if movt or an instruction that satisfies a skip condition is executed when interrupt is accepted instruction ei mov wr, #0010b poke intpm3, wr movt dbf, @ar or skip instruction interrupt cycle inte 1.78 s interrupt enable period int0 pin interrupt accepted int0 pin interrupt service int0 pin irq0 flag ip0 flag 1 instruction cycle m instruction ei mov wr, #0010b poke intpm3, wr normal instruction interrupt cycle inte int0 pin irq0 flag ip0 flag 1 instruction cycle 1.78 s interrupt enable period int0 pin interrupt accepted int0 pin interrupt service m
141 m pd17704, 17705, 17707, 17708, 17709 figure 12-19. timing charts when interrupt is accepted (2/3) (b) if interrupt is kept pending by the interrupt enable flag (2) if two or more interrupts (e.g., int0 pin and int1 pin) are used (a) hardware priority instruction ei mov wr, #0010b poke intpm3, wr interrupt cycle inte int0 pin irq0 flag ip0 flag int0 pin interrupt pending period int0 pin interrupt accepted int0 pin interrupt service instruction ei mov wr, #0110b poke intpm3, wr interrupt cycle inte int0 pin irq0 flag int1 pin int0 pin interrupt pending period int0 pin interrupt accepted int0 pin interrupt service ei interrupt cycle irq1 flag ip0 flag ip1 flag int1 pin interrupt pending period int1 pin interrupt service int1 pin interrupt accepted
m pd17704, 17705, 17707, 17708, 17709 142 figure 12-19. timing charts when interrupt is accepted (3/3) (b) software priority instruction ei mov wr, #0100b poke intpm3, wr interrupt cycle inte int0 pin irq0 flag int1 pin int1 pin interrupt pending period int1 pin interrupt accepted int1 pin interrupt service ei interrupt cycle irq1 flag ip0 flag ip1 flag int0 pin interrupt pending period int0 pin interrupt service int0 pin interrupt accepted mov wr, #0110b poke intpm3, wr
143 m pd17704, 17705, 17707, 17708, 17709 12.7 operations after interrupt has been accepted when an interrupt is accepted, the following operations are sequentially performed automatically. (1) the interrupt enable flip-flop and the interrupt request flag corresponding to the accepted interrupt request are reset to 0. as a result, the other interrupts are disabled. (2) the contents of the stack pointer are decremented by one. (3) the contents of the program counter are saved to an address stack register specified by the stack pointer. at this time, the contents of the program counter are the program memory address after the address at which the interrupt has been accepted. for example, if a branch instruction is executed when the interrupt has been accepted, the contents of the program counter are the branch destination address. if a subroutine call instruction is executed, the contents of the program counter are the call destination address. if the skip condition of a skip instruction is satisfied, the next instruction is executed as nop and then the interrupt is accepted. consequently, the contents of the program counter are the address after that of the instruction that is skipped. (4) the contents of the system registers (except the address register) are saved to the interrupt stack. (5) the contents of the vector address generator corresponding to the interrupt that has been accepted are transferred to the program counter. in other words, execution branches to the interrupt routine. the operations (1) through (5) above require the time of one special instruction cycle (1.78 m s) in which normal instruction execution is not performed. this instruction cycle is called an interrupt cycle. in other words, the time of one instruction cycle (1.78 m s) is required after an interrupt has been accepted until execution branches to the corresponding vector address. 12.8 returning from interrupt routine the interrupt return (reti) instruction is used to return from an interrupt routine to the processing during which an interrupt was accepted. when the reti instruction is executed, the following operations are sequentially performed automatically. (1) the contents of an address stack register specified by the stack pointer are restored to the program counter. (2) the contents of the interrupt stack are restored to the system registers. (3) the contents of the stack pointer are incremented by one. the operations (1) through (3) above require one instruction cycle (1.78 m s) in which the reti instruction is executed. the only difference between the reti instruction and the ret and retsk instructions, which are subroutine return instructions, is the restoration of the bank register and index register in step (2) above.
m pd17704, 17705, 17707, 17708, 17709 144 12.9 external interrupts (ce and int0 through int4 pins) 12.9.1 outline of external interrupts figure 19-20 outlines the external interrupts. as shown in the figure, external interrupt requests are issued at the rising or falling edges of signals input to the int0 through int4 pins, and at the falling edge of the ce pin. whether an interrupt request is issued at the rising or falling edge of an int pin is independently specified by the program. the int0 through int4 and ce pins are schmitt trigger input pins to prevent malfunctioning due to noise. these pins do not accept a pulse input of less than 100 ns. figure 12-20. outline of external interrupts int0 int0 flag ieg0 flag edge detection block schmitt trigger irq0 flag int1 int1 flag ieg1 flag edge detection block schmitt trigger irq1 flag int2 int2 flag ieg2 flag edge detection block schmitt trigger irq2 flag int3 int3 flag ieg3 flag edge detection block schmitt trigger irq3 flag int4 int4 flag ieg4 flag edge detection block schmitt trigger irq4 flag ce ce flag edge detection block schmitt trigger irqce flag int4sel int3sel interrupt control block
145 m pd17704, 17705, 17707, 17708, 17709 12.9.2 edge detection block the edge detection block specifies the valid edge (rising or falling edge) of an input signal that issues the interrupt request of int0 to int4 pins, by using an interrupt edge selection register. figure 12-21 shows the configuration and function of the interrupt edge selection register. figure 12-21. configuration of interrupt edge selection register (1/2) caution the external input delays about 100 ns. name flag symbol b 3 i e g 4 b 2 i n t 4 s e l b 1 i e g 3 b 0 i n t 3 s e l address 1eh read/write r/w interrupt edge selection 1 power-on reset wdt&sp reset ce reset clock stop at resat 0 1 0 0 0 0 0 0 0 0 0 1 interrupt pin (edge detection cricuit operates) general-purpose port pin (edge detection cricuit stops) selects function of p1a2/int3 pin rising edge falling edge selects input edge to issue interrupt request (int3 pin) interrupt pin (edge detection cricuit operates) general-purpose port pin (edge detection cricuit stops) selects function of p1a3/int4 pin rising edge falling edge selects input edge to issue interrupt request (int4 pin) 0 1 0 1 retained retained
m pd17704, 17705, 17707, 17708, 17709 146 figure 12-21. configuration of interrupt edge selection register (2/2) caution the external input is delayed about 100 ns. note that an interrupt request signal may be issued at the time when the interrupt request issuance edge is switched by the interrupt edge selection flags (ieg0 through ieg4). as indicated in the table 12-3, for example, if the ieg0 flag is set to 1 (falling edge), the high level is input from the int0 pin and the ieg0 flag is reset to 0, the edge detection circuit judges that the rising edge is input and an interrupt request is issued. name flag symbol b 3 0 b 2 i e g 2 b 1 i e g 1 b 0 i e g 0 address 1fh read/write r/w interrupt edge selection 2 power-on reset wdt&sp reset ce reset clock stop at resat 00 0 0 0 0 0 0 1 rising edge falling edge selects input edge to issue interrupt request (int0 pin) rising edge falling edge selects input edge to issue interrupt request (int1 pin) rising edge falling edge selects input edge to issue interrupt request (int2 pin) fixed to 0 0 1 0 1 retained retained
147 m pd17704, 17705, 17707, 17708, 17709 table 12-3. issuance of interrupt request by changing ieg flag changes in ieg0 through ieg4 flags status of int0 through int4 pins issuance of interrupt request status of interrupt request flag 1 ? 0 low level not issued retains previous status (falling) (rising) high level issued set to 1 0 ? 1 low level issued set to 1 (rising) (falling) high level not issued retains previous status 12.9.3 interrupt control block the signal levels that are input to the int0 through int4 pins can be detected by using the int0 through int4 flags. because these flags are reset independently of interrupts, when the interrupt function is not used the int0 through int2 pins can be used as a 3-bit input port, and p1a2/int3 and p1a3/int4 pins can be used as a 2- bit general-purpose input port. if the interrupts are not enabled, these ports can be used as general-purpose port pins whose rising or falling edge can be detected by reading the corresponding interrupt request flags. at this time, however, the interrupt request flags are not automatically reset and must be reset by the program. for further information, also refer to 12.2.1 configuration and function of interrupt request flag (irq ) . 12.10 internal interrupts the following six internal interrupts are available. ? timer 0 ? timer 1 ? timer 2 ? timer 3 ? serial interface 0 ? serial interface 1 12.10.1 timer 0, timer 1, timer 2, and timer 3 interrupts interrupt requests are issued at fixed intervals. for details, refer to 13. timer . 12.10.2 serial interface 0 and serial interface 1 interrupts interrupt requests can be issued at the end of a serial output or serial input operation. for details, refer to 16. serial interface .
m pd17704, 17705, 17707, 17708, 17709 148 13. timers timers are used to manage the program execution time. 13.1 outline of timers figure 13-1 outlines the timers. the following five timers are available. ? basic timer 0 ? timer 0 ? timer 1 ? timer 2 ? timer 3 basic timer 0 detects the status of a flip-flop that is set at fixed time intervals in software. timers 0 through 3 are modulo timers and can use interrupts. basic timer 0 can also be used to detect a power failure. timer 3 is multiplexed with the d/a converter. the clock of each timer is created by dividing the system clock (4.5 mhz). figure 13-1. outline of timers (1/2) (1) basic timer 0 (2) timer 0 (3) timer 1 clock selection 4.5 mhz btm0cy flag flip-flop clock selection 4.5 mhz gate control tm0g start/stop 8-bit counter interrupt control coincidence detection overflow modulo register clock selection 4.5 mhz start/stop 8-bit counter interrupt control coincidence detection modulo register
149 m pd17704, 17705, 17707, 17708, 17709 figure 13-1. outline of timers (2/2) (4) timer 2 (5) timer 3 clock selection 4.5 mhz start/stop 8-bit counter interrupt control coincidence detection modulo register clock divider 4.5 mhz start/stop interrupt control coincidence detection multiplexed whih d/a converter modulo register 8-bit counter or 9-bit counter
m pd17704, 17705, 17707, 17708, 17709 150 13.2 basic timer 0 13.2.1 outline of basic timer 0 figure 13-2 outlines basic timer 0. basic timer 0 is used as a timer by detecting in software the btm0cy flag that is set at fixed intervals (100, 50, 20, or 10 ms). if the btm0cy flag is read first after power-on reset, 0 is always read. after that, the flag is set to 1 at fixed intervals. if the ce pin goes high, ce reset is effected in synchronization with the timing at which the btm0cy flag is set next. therefore, a power failure can be detected by reading the content of the btm0cy flag at system reset (power- on reset or ce reset). for the details of power failure detection, refer to 21. reset . figure 13-2. outline of basic timer 0 remarks 1. btm0ck1 and btm0ck0 (bits 1 and 0 of basic timer 0 clock selection register: refer to figure 13-3 ) set the time intervals at which the btm0cy flag is set. 2. btm0cy (bit 0 of basic timer 0 carry register: refer to figure 13-4 ) detects the status of the flip-flop. divider clock selection block 4.5 mhz btm0cy flag selector btm0ck0 flag btm0ck1 flag flip-flop
151 m pd17704, 17705, 17707, 17708, 17709 13.2.2 clock selection block the clock selection block divides the system clock (4.5 mhz) and sets the time interval at which the btm0cy flag is to be set, by using the btm0ck0 and btm0ck1 flags. figure 13-3 shows the configuration of the basic timer 0 clock selection register. figure 13-3. configuration of basic timer 0 clock selection register name flag symbol b 3 0 b 2 0 b 1 b t m 0 c k 1 b 0 b t m 0 c k 0 address 18h read/write r/w basic timer 0 clock selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 0 10 hz (100 ms) 20 hz (50 ms) 50 hz (20 ms) 100 hz (10 ms) fixed to 0 sets time interval at which btm0cy flag is set 00 0 0 1 1 0 0 retained retained
m pd17704, 17705, 17707, 17708, 17709 152 13.2.3 flip-flop and btm0cy flag the flip-flop is set at fixed intervals and its status is detected by the btm0cy flag of the basic timer 0 carry register. when the btm0cy flag is read, it is reset to 0 (read & reset). the btm0cy flag is 0 at power-on reset, and is 1 at ce reset and on execution of the clock stop instruction. therefore, this flag can be used to detect a power failure. the btm0cy flag is not set after power application until an instruction that reads it is executed. once the read instruction has been executed, the flag is set at fixed intervals. figure 13-4 shows the configuration of the basic timer 0 carry register. figure 13-4. configuration of basic timer 0 carry register name flag symbol b 3 0 b 2 0 b 1 0 b 0 b t m 0 c y address 17h read/write r & reset basic timer 0 carry power-on reset wdt&sp reset ce reset r: retained clock stop at reset 0 1 0 r 1 r flip-flop is not set flip-flop is set fixed to 0 detects status of flip-flop 000
153 m pd17704, 17705, 17707, 17708, 17709 13.2.4 example of using basic timer 0 an example of a program using basic timer 0 is shown below. this program executes processing a every 1 second. example clr2 btm0ck1, btm0ck0 ; sets btm0cy flag setting pulse to 10 hz (100 ms) mov m1, #0 loop: skt1 btm0cy ; branches to next if btm0cy flag is 0 br next add m1, #1 ; adds 1 to m1 ske m1, #0ah ; executes processing a if m1 is 10 (1 second has elapsed) br next mov m1, #0 processing a next: processing b ; executes processing b and branches to loop br loop
m pd17704, 17705, 17707, 17708, 17709 154 13.2.5 errors of basic timer 0 errors of basic timer 0 include an error due to the detection time of the btm0cy flag, and an error that occurs when the time interval at which the btm0cy flag is to be set is changed. the following paragraphs (1) and (2) describe each error. (1) error due to detection time of btm0cy flag the time to detect the btm0cy flag must be shorter than the time at which the btm0cy flag is set (refer to 13.2.6 notes on using basic timer 0 ). where the time interval at which the btm0cy flag is detected is t check and the time interval at which the flag is set is t set (100, 50, 20, or 10 ms), t check and t set must relate as follows. t check < t set at this time, the error of the timer when the btm0cy flag is detected is as follows, as shown in figure 13-5. 0 < error < t set figure 13-5. error of basic timer 0 due to detection time of btm0cy flag as shown in figure 13-5, the timer is updated because btm0cy flag is 1 when it is detected in step <2>. when the flag is detected next in step <3>, it is 0. therefore, the timer is not updated until the flag is detected again in <4>. this means that the timer is extended by the time of t check3 . h l btm0cy flag setting pulse t set t check1 skt1 btm0cy <1> skt1 btm0cy <2> skt1 btm0cy <3> skt1 btm0cy <4> t check2 t check3 1 0 btm0cy flag
155 m pd17704, 17705, 17707, 17708, 17709 (2) error when time interval to set btm0cy flag is changed the btm0ck1 and btm0ck0 flags set the time of the btm0cy flag. as described in 13.2.2, four types of timer time-setting pulses can be selected: 10 hz, 20 hz, 50 hz, and 100 hz. at this time, these four pulses operate independently. if the timer time-setting pulse is changed by using the btm0ck1 and btm0ck0 flags, an error occurs as described in the example below. example ; <1> intiflg not btm0ck1, not btm0ck0 ; sets btm0cy flag setting pulse to 10 hz (100 ms) processing a ; <2> initflg btm0ck1, not btm0ck0 ; sets btm0cy flag setting pulse to 50 hz (20 ms) processing a ; <3> initflg not btm0ck1, not btm0ck0 ; sets btm0cy flag setting pulse to 10 hz (100 ms) at this time, the btm0cy flag setting pulse is changed as shown in figure 13-6. figure 13-6. changing btm0cy flag setting pulse as shown in figure 13-6, if the btm0cy flag setting time is changed and the new pulse falls, the btm0cy flag retains the previous status (<2> in the figure). if the new pulse rises, however, the btm0cy flag is set to 1 (<3> in the figure). although changing the pulse setting between 10 hz (100 ms) and 50 hz (20 ms) is described in this example, the same applies to changing the pulse in respect to 20 hz (50 ms) and 100 hz (10 ms). h l internal pulse 10 hz internal pulse 50 hz h l btm0cy flag 1 0 btm0cy flag setting pulse h l skt1 btm0cy <2> <3> <1>
m pd17704, 17705, 17707, 17708, 17709 156 therefore, as shown in figure 13-7, the error of the time until the btm0cy flag is first set after the btm0cy flag setting time has been changed is as follows: Ct set < error < t check t set : new setting time of btm0cy flag t check : time to detect btm0cy flag phase differences are provided among the internal pules of 10, 20, 50, and 100 hz. because these phase differences are shorter than the newly set pulse time, they are included in the above error. figure 13-7. timer error when btm0cy flag setting time is changed from a to b h l h l h l h l t set skt1 btm0cy intrinsic timer time actual timer time time changed internal pulse a internal pulse b btm0cy flag setting pulse btm0cy flag t set t check actual timer time intrinsic timer time time changed an error of t check occurs if the timer time is changed immediately after btm0cy flag has been detected because the flag is then reset once. an error of -t set occurs if btm0cy flag is detected immediately after the timer time has been changed because the flag then becomes 1.
157 m pd17704, 17705, 17707, 17708, 17709 13.2.6 cautions on using basic timer 0 (1) btm0cy flag detection time interval keep the time to detect the btm0cy flag shorter than the time at which the btm0cy flag is set. this is because, if the time of processing b is longer than the time interval at which the btm0cy flag is set as shown in figure 13-8, setting of the btm0cy flag is overlooked. figure 13-8. btm0cy flag detection and btm0cy flag (2) timer updating processing time and btm0cy flag detection time interval as described in (1) above, time interval t set at which the btm0cy flag is detected must be shorter than the time for which to set the btm0cy flag. at this time, even if the time interval at which the btm0cy flag is detected is short, if the updating processing time of the timer is long the processing of the timer may not be executed normally at ce reset. therefore, the following condition must be satisfied. t check + t timer < t set t check : time to detect btm0cy flag t timer : timer updating processing time t set : time to set btm0cy flag an example is given below. h btm0cy flag setting pulse btm0cy flag l skt1 btm0cy skt1 btm0cy processing a processing b skt1 btm0cy t set <1> <2> <3> <4> <5> 1 0 because execution time of processing b takes too long after detection of btm0cy flag that has been set to 1 in <2>, btm0cy flag that is set to 1 in <3> cannot be detected.
m pd17704, 17705, 17707, 17708, 17709 158 example example of timer updating processing and btm0cy flag detection time interval start: clr2 btm0ck1, btm0ck0 ; sets btm0cy flag setting pulse to 10 hz (100 ms) btimer: ; <1> skt1 btm0cy ; updates timer if btm0cy flag is 1 br aaa timer updating br btimer aaa: processing a br btimer the timing chart of the above program is shown below. (3) compensating basic timer 0 carry at ce reset next, an example of compensating the timer at ce reset is described below. as shown in the example below, the timer must be compensated at ce reset if the btm0cy flag is used for power failure detection and if the btm0cy flag is used for a watch timer. the btm0cy flag is reset (to 0) first on power application (power-on reset), and is disabled from being set until it is read once by the peek instruction. if the ce pin goes high, ce reset is effected in synchronization with the rising edge of the btm0cy flag setting pulse. at this time, the btm0cy flag is set (to 1) and the timer is started. by detecting the status of the btm0cy flag at system reset (power-on reset or ce reset), therefore, it can be identified whether a power-on reset or ce reset has been effected (power failure detection). that is, power-on reset has been effected if the flag is 0, and ce reset has been effected if it is 1. at this time, the watch timer must continue operating even if ce reset has been effected. however, because the btm0cy flag is reset to 0 when it is read to detect a power failure, the set status (1) of the btm0cy flag is overlooked once. if the delay function of ce reset is used, the value set to the ce reset timer carry counter (control register address 06h) is overlooked. consequently, the watch timer must be updated if ce reset is identified by means of power failure detection. for the details of power failure detection, refer to 21. reset . t set h ce pin btm0cy detection interval t check timer updating processing t timer btm0cy flag btm0cy flag setting pulse l h l 1 <1> skt1 btm0cy <2> skt1 btm0cy ce reset 0 if this timer updating processing time is too long, ce reset is effected during processing.
159 m pd17704, 17705, 17707, 17708, 17709 example example of compensating timer at ce reset (to detect power failure and update watch timer using btm0cy flag) start: ; program address 0000h processing a ; <1> skt1 btm0cy ; embedded macro ; tests btm0cy flag br initial ; if 0, branches to initial (power failure detection) backup: ; <2> 100-ms watch updating ; compensates watch timer because of backup (ce reset) ; initial value 1 is stored as ce reset timer carry ; counter value loop: ; <3> processing b : while performing processing b, skf1 btm0cy ; tests btm0cy flag and updates watch timer br backup br loop initial: clr2 btm0ck1, btm0ck0 ; embedded macro ; because power failure (power-on reset) occurs, ; sets setting time of btm0cy flag to 100 ms, and ; executes processing c processing c br loop figure 13-9 shows the timing chart of the above program.
m pd17704, 17705, 17707, 17708, 17709 160 figure 13-9. timing chart as shown in figure 13-9, the program is started from address 0000h because the internal 10-hz pulse rises when supply voltage v dd is first applied. when the btm0cy flag is detected at point a, it is judged that the btm0cy flag is reset (to 0) and that a power failure (power-on reset) has occurred because the power has just been applied. therefore, processing c is executed, and the btm0cy flag setting pulse is set to 100 ms. because the content of the btm0cy flag is read once at point a, the btm0cy flag will be set to 1 every 100 ms. next, even if the ce pin goes low at point b and high at point c, the program counts up the watch timer while executing processing b, unless the clock stop instruction is executed. at point c, because the ce pin goes high, ce reset is effected at point d at which the btm0cy flag setting pulse rises next time, and the program is started from address 0000h. when the btm0cy flag is detected at point e at this time, it is set to 1. therefore, this is judged to be a back up (ce reset). as is evident from the above figure, unless the watch is updated by 100 ms at point e, the watch is delayed by 100 ms each time ce reset is effected. if processing a takes longer than 100 ms when a power failure is detected at point e, the setting of the btm0cy flag is overlooked two times. therefore, processing a must be completed within 100 ms. the above description also applies when the btm0cy flag setting pulse is set to 50, 20, or 10 ms. therefore, the btm0cy flag must be detected for power failure detection within the btm0cy flag setting time after the program has been started from address 0000h. a power-on reset start from address 0 ce reset start from address 0 application of supply voltage btm0cy flag detected c 5 v v dd ce btm0cy flag setting pulse (10 hz) btm0cy flag program processing program instruction 0 v h l h l 1 0 bb b b b bbb bb <3> watch up <3> watch up <3> watch up <3> <3> <1> watch up <3> <3> <3> <3> <3> <1> a updates watch timer because setting of btm0cy flag (to 1) is detected point a point b point c point d point e
161 m pd17704, 17705, 17707, 17708, 17709 (4) if btm0cy flag is detected at the same time as ce reset as described in (3) above, ce reset is effected as soon as the btm0cy flag is set to 1. if the instruction that reads the btm0cy flag happens to be executed at the same time as ce reset at this time, the btm0cy flag reading instruction takes precedence. therefore, if the next setting the btm0cy flag (rising of btm0cy flag setting pulse) after the ce pin has gone high coincides with execution of the btm0cy flag reading instruction, ce reset is effected at the next timing at which the btm0cy flag is set. this operation is illustrated in figure 13-10. figure 13-10. operation when ce reset coincides with btm0cy flag reading instruction consequently, if the btm0cy flag detection time interval coincides with the btm0cy flag setting time in a program that cyclically detects the btm0cy flag, ce reset is never effected. therefore, the following point must be noted. because one instruction cycle is 1.78 m s (1/562.5 khz), a program that detects the btm0cy flag once, say, every 1125 instructions, reads the btm0cy flag every 1.78 m s 1125 = 2 ms. because the timer time setting pulse is 100 ms at this time, if setting and detection of the btm0cy flag coincide once, ce reset is never effected. h btm0cy flag setting pulse btm0cy flag ce pin l h l 1.78 s skt1 btm0cy (peek ) skt1 btm0cy ce reset (skt ) 1 0 h btm0cy flag setting pulse btm0cy flag instruction embedded macro peek wr, . mf. btm0cy shr 4 skt wr, #. df. btm0cy and 000fh l 1 0 if btm0cy flag is read at this time, ce reset is effected delayed once. originally, program is started from address 0000h here. however, ce reset is not effected because it happens to coincide with program that reads btm0cy flag. skt1 btm0cy
m pd17704, 17705, 17707, 17708, 17709 162 therefore, do not create a cyclic program that satisfies the following condition. t set 1125 = n (n: natural number) x t set : b tm0cy flag setting time x : cycle x step of instruction that reads btm0cy flag an example of a program that satisfies the above condition is shown below. do not create such a program. example processing a clr2 btm0ck1, btm0ck0 ; embedded macro ; sets btm0cy flag setting pulse to 100 ms loop: ; <1> skt1 btm0cy ; embedded macro br bbb aaa: 1121 steps br loop bbb: 1121 steps br loop because the btm0cy flag reading instruction in <1> is repeatedly executed every 1125 instruction in this example, ce reset is not effected if the btm0cy flag happens to be set at the timing of instruction in <1>.
163 m pd17704, 17705, 17707, 17708, 17709 13.3 timer 0 13.3.1 outline of timer 0 figure 13-11 shows the outline of timer 0. the timer 0 is used as timer (modulo mode) by comparing the count value with the previously set value after the basic clock (100 khz, 10 khz, 2 khz, and 1 khz) has counted by the 8-bit counter. the pulse width of the signal input from the tm0g pin can be measured (external gate counter). figure 13-11. outlines timer 0 remarks 1. tm0ck1 and tm0ck0 (bits 1 and 0 of timer 0 counter clock selection register: refer to figure 13-13 ) set a basic clock frequency. 2. tm0md (bit 0 of timer 0 mode selection register: refer to figure 13-14 ) selects the modulo counter and gate counter. 3. tm0goeg (bit 1 of timer 0 mode selection register: refer to figure 13-14 ) sets the open edge of an external gate. 4. tm0gceg (bit 2 of timer 0 mode selection register: refer to figure 13-14 ) sets the close edge of an external gate. 5. tm0ovf (bit 3 of timer 0 mode selection register: refer to figure 13-14 ) detects an overflow of timer 0 counter. 6. tm0res (bit 2 of timer 0 counter clock selection register: refer to figure 13-13 ) resets timer 0 counter. clock selection 4.5 mhz gate control p1a0/tm0g start/stop timer 0 counter (tm0c) tm0ck1 flag tm0ck0 flag tm0gceg flag tm0goeg flag tm0md flag tm0md flag coincidence detection circuit 8 tm0res flag dbf gate closed overflow sets irqtm0 flag tm0ovf flag dbf 8 timer 0 modulo register (tm0m)
m pd17704, 17705, 17707, 17708, 17709 164 13.3.2 clock selection, start/stop control, and gate control blocks figure 13-12 shows the configuration of these blocks. the clock selection block selects a basic clock to operate timer 0 counter. four types of basic clocks can be selected by using the tm0ck1 and tm0ck0 flags. figure 13-13 shows the configuration and function of each flag. the start/stop block controls the tm0md flag and open/close signal from the gate control block, and starts or stops the basic clock to be input to timer 0 counter by the tm0en flag. the gate control block sets the opening or closing conditions of the gate. it sets whether the gate is opened or closed by a rising or falling of the input signal, by using the tm0goeg and tm0gceg flags. this block also issues an interrupt request when the closing condition of the gate is detected. figure 13-14 shows the configuration and function of each flag. figure 13-12. configuration of clock selection, start/stop control, and gate control blocks selector 100 khz 10 khz 2 khz 1 khz tm0ck1 tm0ck0 clock selection divider 4.5 mhz start/stop timer 0 counter tm0en flag tm0md flag tm0md flag p1a0/tm0g tm0goeg tm0gceg gate control open/ close edge detection timer 0 interrupt
165 m pd17704, 17705, 17707, 17708, 17709 figure 13-13. configuration of timer 0 counter clock selection register caution when the tm0res flag is read, 0 is always read. name flag symbol b 3 t m 0 e n b 2 t m 0 r e s b 1 t m 0 c k 1 b 0 t m 0 c k 0 address 2bh read/write r/w timer 0 counter clock selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 0 0 100 khz (10 s) 10 khz (100 s) 2 khz (500 s) 1 khz (1 ms) sets basic clock of timer 0 counter 0 0 0 0 0 0 0 0 1 1 does not change resets counter resets timer 0 counter 0 1 0 0 0 retained stops starts starts or stops timer 0 0 1 m m m
m pd17704, 17705, 17707, 17708, 17709 166 13.3.3 count block the count block counts the basic clock with an 8-bit timer 0 counter, reads the count value, and issues an interrupt request if the value of the timer 0 modulo register coincides with its value. timer 0 counter can be reset by the tm0res flag. the tm0ovf flag can detect an overflow of the counter. when an overflow occurs, an interrupt request can be issued. the value of the timer 0 counter can be read via data buffer. the value of the timer 0 modulo register can be written or read via data buffer. figure 13-14 shows the configuration of the timer 0 mode selection register. figure 13-15 shows the configuration of the timer 0 counter. figure 13-16 shows the configuration of the timer 0 modulo register. figure 13-14. configuration of timer 0 mode selection register name flag symbol b 3 t m 0 o v f b 2 t m 0 g c e g b 1 t m 0 g o e g b 0 t m 0 m d address 2ch read/write r/w timer 0 mode selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 0 0 modulo counter gate counter selects modulo counter or gate counter of timer 0 0 0 0 0 0 0 rising edge falling edge rising edge falling edge specifies edge of gate open input signal 0 1 0 0 0 retained specifies edge of gate close input signal 0 1 no overflow overflow detects timer 0 overflow 0 1
167 m pd17704, 17705, 17707, 17708, 17709 figure 13-15. configuration of timer 0 counter reads count value of timer 0 data buffer dbf3 don't care dbf2 don't care name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 6 b 5 b 4 timer 0 counter tm0c 1bh power-on reset wdt&sp reset ce reset clock stop 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 retained transfer data valid data 0 ? modulo mode reset if count value of timer 0 coincides with value of modulo counter. ? external gate mode resets counting to 00h if overflow occurs 0ffh 8 bits get put must not be executed at reset
m pd17704, 17705, 17707, 17708, 17709 168 figure 13-16. configuration of timer 0 modulo register sets modulo data of timer 0 data buffer dbf3 don't care dbf2 don't care name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 6 b 5 b 4 timer 0 modulo register tm0m 1ah power-on reset wdt&sp reset ce reset clock stop at reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 retained transfer data valid data 0 ? modulo mode issues interrupt request when value of modulo counter coincides with count value of timer 0. ? external gate mode does not issue interrupt request when value of modulo counter coincides with count value of timer 0. 0ffh 8 bits get put
169 m pd17704, 17705, 17707, 17708, 17709 13.3.4 example of using timer 0 (1) modulo counter mode the modulo counter mode is used for time management by generating timer 0 interrupt at fixed intervals. an example of a program is shown below. this program executes processing b every 500 m s. tm0data dat 0032h ; modulo data = 50 start: br initial ; reset address ; interrupt vector address nop ; sio1 nop ; sio0 nop ; tm3 nop ; tm2 nop ; tm1 br int_tm0 ; tm0 nop ; int4 nop ; int3 nop ; int2 nop ; int1 nop ; int0 nop ; down edge of ce initial: initflg not tm0en, tm0res, not tm0ck1, not tm0ck0 ; (stop) , (reset) , (basic clock = 10 m s) clr1 tm0md ; modulo mode mov dbf0, #(tm0mdata shr 0) and 0fh mov dbf1, #(tm0mdata shr 4) and 0fh put tm0m, dbf ; sets count data set1 iptm0 ; enables timer 0 interrupt ei set1 tm0en ; starts timer 0 loop: processing a br loop int_tm0: processing b ; timer 0 interrupt service ei reti ; return
m pd17704, 17705, 17707, 17708, 17709 170 (2) gate counter mode the gate counter mode is used to count the width of a pulse input to the tm0g pin. an example of a program is shown below. in this program example, the width of the pulse input to the tm0g pin is counted from the falling edge to the falling edge. if the pulse width is 800 to 1200 m s, processing c is executed; otherwise, processing b is executed. if the pulse width is 2560 m s or more, processing d is executed. tm0800 dat 0050h ; count data = 80 tm01200 dat 0078h ; count data = 120 start: br initial ; reset address ; interrupt vector address nop ; sio1 nop ; sio0 nop ; tm3 nop ; tm2 nop ; tm1 br int_tm0 ; tm0 nop ; int4 nop ; int3 nop ; int2 nop ; int1 nop ; int0 nop ; down edge of ce initial: initflg not tm0en, tm0res, not tm0ck1, not tm0ck0 ; (stop) , (reset) , (basic clock = 10 m s) initflg tm0gceg , tm0goeg , tm0md ; (falling close), (falling open), (gate counter) set1 tm0en ; start set1 iptm0 ; enables timer 0 interrupt ei loop: processing a br loop int_tm0: put dbfstk, dbf ; saves data buffer get dbf, tm0c initflg tm0en, tm0res skt1 tm0ovf ; detects overflow status (2560 m s or more?) br aaa processing d br ei_reti aaa: sub dbf0, #tm0800 and 0fh subc dbf1, #tm0800 shr4 and 0fh skf1 cy ; 800 m s or more? br bbb sub dbf0, #tm01200 and 0fh
171 m pd17704, 17705, 17707, 17708, 17709 subc dbf1, #tm01200 shr4 and 0fh skt1 cy ; 1200 m s or more? br bbb processing c br ei_reti bbb: processing b ei_reti: get dbf, dbfstk ; restores data buffer ei reti ; return end 13.3.5 error of timer 0 timer 0 has an error of up to 1 basic clock in the following cases. (1) on starting/stopping counter the counter is started or stopped by anding the open/close condition of the gate and tm0en flag setting condition. therefore, an error of 0 to +1 clocks occurs when the gate is opened or the tm0en flag is set, and an error of C1 to 0 clocks occurs when the gate is closed or the flag is reset. in all, an error of 1 count occurs. (2) on resetting counter operation an error of 0 to +1 clocks occurs when the counter is reset. (3) on selecting basic clock during counter operation an error of 0 to +1 clocks of the newly selected clock occurs. 13.3.6 cautions on using timer 0 timer 0 interrupt may occur simultaneously with the other timer interrupts and ce reset. if it is necessary to update the timer at ce reset, do not use timer 0, use basic timer 0 instead.
m pd17704, 17705, 17707, 17708, 17709 172 13.4 timer 1 13.4.1 outline of timer 1 figure 13-17 outlines timer 1. timer 1 counts the basic clock (100, 10, 2, or 1 khz) with an 8-bit counter, and compares the count value with a value set in advance. figure 13-17. outline of timer 1 remarks 1. tm1ck1 and tm1ck0 (bits 1 and 0 of timer 1 counter clock selection register: refer to figure 13-18 ) set the basic clock frequency. 2. tm1en (bit 3 of timer 1 counter clock selection register: refer to figure 13-18 ) starts or stops timer 1. 3. tm1res (bit 2 of timer 1 counter clock selection register: refer to figure 13-18 ) resets timer 1 counter. clock selection 4.5 mhz start/stop timre 1 counter (tm1c) tm1ck1 flag tm1ck0 flag tm1en flag coincidence detection circuit tm1res flag dbf timer 1 irqtm1 flag interrupt control dbf timer 1 modulo register (tm1m)
173 m pd17704, 17705, 17707, 17708, 17709 13.4.2 clock selection and start/stop control blocks the clock selection block selects a basic clock to operate timer 1 counter. four types of basic clocks can be selected by using the tm1ck1 and tm1ck0 flags. the start/stop block starts or stops the basic clock input to timer 1 by using the tm1en flag. figure 13-18 shows the configuration and function of each flag. 13.4.3 count block the count block counts the basic clock with timer 1 counter, reads the count value, and issues an interrupt request when its count value coincides with the value of the timer 1 modulo register. the timer 1 counter can be reset by the tm1res flag. the timer 1 counter is automatically reset when its value coincides with the value of the timer 1 modulo register. the value of the timer 1 counter can be read via data buffer. data can be written to the value of the timer 1 modulo register via data buffer. figure 13-18 shows the configuration of timer 1 counter clock selection register. figure 13-19 shows the configuration of the timer 1 counter. figure 13-20 shows the configuration of the timer 1 modulo register.
m pd17704, 17705, 17707, 17708, 17709 174 figure 13-18. configuration of timer 1 counter clock selection register caution when the tm1res flag is read, 0 is always read. name flag symbol b 3 t m 1 e n b 2 t m 1 r e s b 1 t m 1 c k 1 b 0 t m 1 c k 0 address 2ah read/write r/w timer 1 counter clock selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 0 0 100 khz (10 s) 10 khz (100 s) 2 khz (500 s) 1 khz (1 ms) sets basic clock of timer 1 counter 0 0 0 0 0 0 0 0 1 1 does not change resets counter resets timer 1 counter (valid on writing) 0 1 0 0 0 retained stops starts starts or stops timer 1 0 1 m m m
175 m pd17704, 17705, 17707, 17708, 17709 figure 13-19. configuration of timer 1 counter reads count value of timer 1 data buffer dbf3 don't care dbf2 don't care name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 6 b 5 b 4 timer 1 counter tm1c 1dh power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 retained transfer data valid data 0 x count value 0ffh 8 bits get put must not be executed
m pd17704, 17705, 17707, 17708, 17709 176 figure 13-20. configuration of timer 1 modulo register sets modulo data of timer 1 data buffer dbf3 don't care dbf2 don't care name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 6 b 5 b 4 timer 1 modulo register tm1m 1ch power-on reset wdt&sp reset ce reset clock stop at reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 retained transfer data valid data 0 1 x setting prohibited modulo counter value 0ffh 8 bits get put
177 m pd17704, 17705, 17707, 17708, 17709 13.4.4 example of using timer 1 (1) modulo timer the modulo timer is used for time management by generating timer 1 interrupt at fixed intervals. an example of a program is shown below. this program executes processing b every 500 m s. tm1data dat 0032h ; count data = 50 start: br initial ; reset address ; interrupt vector address nop ; sio1 nop ; sio0 nop ; tm3 nop ; tm2 br int_tm1 ; tm1 nop ; tm0 nop ; int4 nop ; int3 nop ; int2 nop ; int1 nop ; int0 nop ; down edge of ce initial: initflg not tm1en, tm1res, not tm1ck1, not tm1ck0 ; (stop) , (reset) , (basic clock = 10 m s) mov dbf0, #tm1data mov dbf1, #tm1data shr4 and 0fh put tm1, dbf set1 tm1en ; start set1 iptm1 ; enables timer 1 interrupt ei loop: processing a br loop int_tm1: put dbfstk, dbf ; saves data buffer processing b get dbf, dbfstk ei reti ; return end
m pd17704, 17705, 17707, 17708, 17709 178 13.4.5 error of timer 1 timer 1 has an error of up to 1 basic clock in the following cases. (1) on starting/stopping counter the counter is started or stopped by setting the tm1en flag. therefore, an error of 0 to +1 clocks occurs when the tm1en flag is set, and an error of C1 to 0 clocks occurs when the flag is reset. in all, an error of 1 count occurs. (2) on resetting counter operation an error of 0 to +1 clocks occurs when the counter is reset. (3) on selecting basic clock during counter operation an error of 0 to +1 clocks of the newly selected clock occurs. 13.4.6 cautions on using timer 1 timer 1 interrupt may occur simultaneously with the other timer interrupts and ce reset. if it is necessary to update the timer at ce reset, do not use timer 1, use basic timer 0 instead.
179 m pd17704, 17705, 17707, 17708, 17709 13.5 timer 2 13.5.1 outline of timer 2 figure 13-21 outlines timer 2. timer 2 counts the basic clock (100, 10, 2, or 1 khz) with an 8-bit counter, and compares the count value with a value set in advance. figure 13-21. outline of timer 2 remarks 1. tm2ck1 and tm2ck0 (bits 1 and 0 of timer 2 counter clock selection register: refer to figure 13-22 ) set the basic clock frequency. 2. tm2en (bit 3 of timer 2 counter clock selection register: refer to figure 13-22 ) starts or stops timer 2. 3. tm2res (bit 2 of timer 2 counter clock selection register: refer to figure 13-22 ) resets timer 2 counter. clock selection 4.5 mhz start/stop timer 2 counter (tm2c) tm2ck1 flag tm2ck0 flag tm2en flag coincidence detection circuit tm2res flag dbf timer 2 irqtm2 flag interrupt control dbf timer 2 modulo register (tm2m)
m pd17704, 17705, 17707, 17708, 17709 180 13.5.2 clock selection and start/stop control blocks the clock selection block selects a basic clock to operate timer 2 counter. four types of basic clocks can be selected by using the tm2ck1 and tm2ck0 flags. the start/stop block starts or stops the basic clock input to timer 2 by using the tm2en flag. figure 13-22 shows the configuration and function of each flag. 13.5.3 count block the count block counts the basic clock with timer 2 counter, reads the count value, and issues an interrupt request when its count value coincides with the value of the timer 2 modulo register. the timer 2 counter can be reset by the tm2res flag. the timer 2 counter is automatically reset when its value coincides with the value of the timer 2 modulo register. the value of the timer 2 counter can be read via data buffer. data can be written to the value of the timer 2 modulo register via data buffer. figure 13-22 shows the configuration of timer 2 counter clock selection register. figure 13-23 shows the configuration of the timer 2 counter. figure 13-24 shows the configuration of the timer 2 modulo register.
181 m pd17704, 17705, 17707, 17708, 17709 figure 13-22. configuration of timer 2 counter clock selection register caution when the tm2res flag is read, 0 is always read. name flag symbol b 3 t m 2 e n b 2 t m 2 r e s b 1 t m 2 c k 1 b 0 t m 2 c k 0 address 29h read/write r/w timer 2 counter clock selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 0 0 100 khz (10 s) 10 khz (100 s) 2 khz (500 s) 1 khz (1 ms) sets basic clock of timer 2 counter 0 0 0 0 0 0 0 0 1 1 does not change resets counter resets timer 2 counter (valid on writing) 0 1 0 0 0 retained stops starts starts or stops timer 2 0 1 m m m
m pd17704, 17705, 17707, 17708, 17709 182 figure 13-23. configuration of timer 2 counter reads count value of timer 2 data buffer dbf3 don't care dbf2 don't care name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 6 b 5 b 4 timer 2 counter tm2c 1fh power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 retained transfer data valid data 0 x count value 0ffh 8 bits get put must not be executed
183 m pd17704, 17705, 17707, 17708, 17709 figure 13-24. configuration of timer 2 modulo register sets modulo data of timer 2 data buffer dbf3 don't care dbf2 don't care name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 6 b 5 b 4 timer 2 modulo register tm2m 1eh power-on reset wdt&sp reset ce reset clock stop at reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 retained transfer data valid data 0 1 x setting prohibited modulo counter value 0ffh 8 bits get put
m pd17704, 17705, 17707, 17708, 17709 184 13.5.4 example of using timer 2 (1) modulo timer the modulo timer is used for time management by generating a timer 2 interrupt at fixed intervals. an example of a program is shown below. this program executes processing b every 500 m s. tm2data dat 0032h ; count data = 50 start: br initial ; reset address ; interrupt vector address nop ; sio1 nop ; sio0 nop ; tm3 br int_tm2 ; tm2 nop ; tm1 nop ; tm0 nop ; int4 nop ; int3 nop ; int2 nop ; int1 nop ; int0 nop ; down edge of ce initial: initflg not tm2en, tm2res, not tm2ck1, not tm2ck0 ; (stop) , (reset) , (basic clock = 10 m s) mov dbf0, #tm2data mov dbf1, #tm2data shr4 and 0fh put tm2, dbf set1 tm2en ; start set1 iptm2 ; enables timer 2 interrupt ei loop: processing a br loop int_tm2: put dbfstk, dbf ; saves data buffer initflg tm2en, tm2res ; resets and starts processing b get dbf, dbfstk ei reti ; return end
185 m pd17704, 17705, 17707, 17708, 17709 13.5.5 error of timer 2 timer 2 has an error of up to 1 basic clock in the following cases. (1) on starting/stopping counter the counter is started or stopped by setting the tm2en flag. therefore, an error of 0 to +1 clocks occurs when the tm2en flag is set, and an error of C1 to 0 clocks occurs when the flag is reset. in all, an error of 1 count occurs. (2) on resetting counter operation an error of 0 to +1 clocks occurs when the counter is reset. (3) on selecting basic clock during counter operation an error of 0 to +1 clocks of the newly selected clock occurs. 13.5.6 cautions on using timer 2 timer 2 interrupt may occur simultaneously with the other timer interrupts and ce reset. if it is necessary to update the timer at ce reset, do not use timer 2, use basic timer 0 instead.
m pd17704, 17705, 17707, 17708, 17709 186 13.6 timer 3 13.6.1 outline of timer 3 figure 13-25 outlines timer 3. timer 3 counts the basic clock (1.125 mhz or 112.5 khz selectable) with an 8-bit counter note , and compares the count value with a value set in advance. because timer 3 is multiplexed with a d/a converter, all the three d/a converter pins are automatically set in the general-purpose port mode when timer 3 is used. note a 9-bit or 8-bit counter can be selected for the d/a converter, but the 8-bit counter is automatically selected when the timer function is selected. figure 13-25. outline of timer 3 remarks 1. pwmck (bit 0 of pwm clock selection register: refer to figure 13-26 ) selects the output frequency of timer 3. 2. tm3sel (bit 3 of timer 3 control register: refer to figure 13-27 ) selects timer 3 or d/a converter. 3. tm3en (bit 1 of timer 3 control register: refer to figure 13-27 ) starts or stops counting by timer 3. 4. tm3res (bit 0 of timer 3 control register: refer to figure 13-27 ) controls resetting of timer 3 counter. clock selection 4.5 mhz start/stop timer 3 counter (tm3c) pwmck flag tm3en flag tm3sel flag coincidence detection circuit tm3res flag dbf irqtm3 flag interrupt control timer 3 modulo register ( tm3m )
187 m pd17704, 17705, 17707, 17708, 17709 13.6.2 clock selection block the clock of timer 3 is selected by the pwmck flag of the pwm clock selection register. figure 13-26 shows the configuration of the flag. figure 13-26. configuration of pwm clock selection register name flag symbol b 3 0 b 2 p w m b i t b 1 0 b 0 p w m c k address 26h read/write r/w pwm clock selection power-on reset wdt&sp reset ce reset clock stop r:retained at reset 0 1 0 0 r 0 4.4 khz (8 bits)/2.2 khz (9 bits) 440 hz (8 bits)/220 hz (9 bits) selects output frequency of timer 3 00 0 r 0 fixed to 0 fixed to 0 8 bits 9 bits 0 selects number of bits of pwm counter 0 1
m pd17704, 17705, 17707, 17708, 17709 188 13.6.3 start/stop control block the start/stop block starts or stops the basic clock to be input to timer 3 counter by using the tm3en flag. to control timer 3, timer 3 must be selected by the tm3sel flag. figure 13-27 shows the configuration of each flag. figure 13-27. configuration of timer 3 control register name flag symbol b 3 t m 3 s e l b 2 0 b 1 t m 3 e n b 0 t m 3 r e s address 28h read/write r/w timer 3 control 0 1 dose not change resets resets counter stop starts fixed to 0 starts or stops counter 0 1 d/a converter (pwm output) timer 3 selects timer 3 or d/a converter 0 1 power-on reset wdt&sp reset ce reset clock stop r:retained at reset 0 0 0 0 0 0 r 0 0 0 0 retained
189 m pd17704, 17705, 17707, 17708, 17709 13.6.4 count block the count block counts the basic clock with timer 3 and issues an interrupt request when the count value of timer 3 coincides with the value of the timer 3 modulo register. timer 3 counter can be reset by the tm3res flag. because the pwm data register 2 (pwmr2) and timer 3 modulo register (tm3m) are multiplexed, these registers cannot be used at the same time. when timer 3 is used, the pwm data register 1 (pwmr1) and pwm data register 0 (pwmr0) can be used as 9-bit data latches (refer to 15. d/a converter (pwm mode) ). figure 13-28. configuration of timer 3 modulo register note this register is multiplexed with the pwm data register. sets modulo data of timer 3 data buffer dbf3 dbf2 name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 8 b 9 0 b 10 0 b 11 0 b 12 0 b 13 0 b 14 0 b 15 0 b 6 b 5 b 4 timer 3 modulo register note tm3m 46h power-on reset wdt&sp reset ce reset clock stop at reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 retained transfer data valid data 0 x modulo counter value fixed to ? 1ffh 16 bits get put
m pd17704, 17705, 17707, 17708, 17709 190 13.6.5 example of using timer 3 an example of a program using timer 3 (multiplexed with pwm) is given below. this program executes processing b every 888 m s. tm3data dat 0064h ; count data = 100 start: br initial ; reset address ; interrupt vector address nop ; sio1 nop ; sio0 br int_tm3 ; tm3 nop ; tm2 nop ; tm1 nop ; tm0 nop ; int4 nop ; int3 nop ; int2 nop ; int1 nop ; int0 nop ; down edge of ce initial: initflg not pwmsel2 , not pwmsel1 , not pwmsel0 ; (general-purpose port), (general-purpose port), (general-purpose port) initflg not pwmbit, pwmck ; ( 8bit ), (440 hz) initflg tm3sel , not tm3en, tm3res ; (timer 3 mode), (stop) , (reset) mov dbf0, #tm3data mov dbf1, #tm3data shr4 and 0fh put tm3m, dbf set1 tm3en ; start set1 iptm3 ; enables timer 3 interrupt ei loop: processing a br loop int_tm3: put dbfstk, dbf ; saves data buffer processing b get dbf, dbfstk ei reti ; return end
191 m pd17704, 17705, 17707, 17708, 17709 13.6.6 error of timer 3 timer 3 has an error of up to 1 basic clock in the following cases. (1) on starting/stopping counter the counter is started or stopped by setting the tm3en flag. therefore, an error of 0 to +1 clocks occurs when the tm3en flag is set, and an error of C1 to 0 clocks occurs when the flag is reset. in all, an error of 1 count occurs. (2) on resetting counter operation an error of 0 to +1 clocks occurs when the counter is reset. (3) on selecting basic clock during counter operation an error of 0 to +1 clocks of the newly selected clock occurs. 13.6.7 cautions on using timer 3 timer 3 interrupt may occur simultaneously with the other timer interrupts and ce reset. if it is necessary to update the timer at ce reset, do not use timer 3, use basic timer 0 instead. when timer 3 is used, the three output port pins multiplexed with the d/a converter pins, p1b2/pwm2 through p1b0/pwm0, are automatically set in the general-purpose output port mode.
m pd17704, 17705, 17707, 17708, 17709 192 13.6.8 status at reset (1) at power-on reset the p1b2/pwm2 through p1b0/pwm0 pins are set in the general-purpose output port mode. the output value is low level. the value of each pwm data register (including the timer 3 modulo register) is 1ffh. (2) at wdt&sp reset the p1b2/pwm2 through p1b0/pwm0 pins are set in the general-purpose output port mode. the output value is low level. the value of each pwm data register (including the timer 3 modulo register) is 1ffh. (3) on execution of clock stop instruction the p1b2/pwm2 through p1b0/pwm0 pins are set in the general-purpose output port mode. the output value is the previous contents of the output latch. the value of each pwm data register (including the timer 3 modulo register) is 1ffh. (4) at ce reset the previous status is retained. that is, if the d/a converter is being used, the pwm output is retained as is. if timer 3 is being used, counting continues. while timer 3 is being used, the di status is set (in which all interrupts are disabled). (5) in halt status the previous status is retained. that is, if the d/a converter is being used, the pwm output is retained as is. if timer 3 is being used, counting continues.
193 m pd17704, 17705, 17707, 17708, 17709 14. a/d converter 14.1 outline of a/d converter figure 14-1 outlines the a/d converter. the a/d converter converts an analog voltage input to the ad5 to ad0 pins into an 8-bit digital signal. two modes can be selected by using the adcmd flag: software mode and hardware mode. in the software mode, a voltage input to a pin is compared with an internal reference voltage, and the result of the comparison is detected by the adccmp flag. by judging this result in software and by sequentially selecting reference voltages, the a/d converter can be used as a successive approximation a/d converter. in the hardware mode, reference voltages are automatically selected, and the input voltage is directly detected as 8-bit digital data. figure 14-1. outline of a/d converter remarks 1. adcch2 through adcch0 (bits 2 through 0 of a/d converter channel selection register: refer to figure 14-3 ) select pins used for the a/d converter. 2. adccmp (bit 0 of a/d converter mode selection register: refer to figure 14-5 ) detects the result of comparison. 3. adcstt (bit 1 of a/d converter mode selection register: refer to figure 14-5 ) detects the operating status. 4. adcmd (bit 2 of a/d converter mode selection register: refer to figure 14-5 ) selects software or hardware mode. p1c3/ad5 p1c2/ad4 p0d3/ad3 p0d2/ad2 p0d1/ad1 p0d0/ad0 adcch2 flag adcch1 flag adcch0 flag input selection block compare voltage generation block r-string d/a converter dbf adcmd flag adccmp flag adcstt flag start/stop control block compare block
m pd17704, 17705, 17707, 17708, 17709 194 14.2 input selection block figure 14-2 shows the configuration of the input selection block. the input selection block selects a pin to be used by using the adcch2 through adcch0 flags. only one pin can be used for the a/d converter. when one of the p0d0/ad0 through p0d3/ad3, p1c2/ad4, and p1c3/ ad5 pins is selected, the other five pins are forcibly set in the input port mode. the p0d0/ad0 through p0d3/ad3 pins can be connected to a pull-down resistor if so specified by the p0dpl0 through p0dpld3 flags. to use the p0d0/ad0 through p0d3/ad3 pins for the a/d converter, therefore, disconnect their pull-down resistors to correctly detect an external input analog voltage. figure 14-3 shows the configuration of the a/d converter channel selection register. figure 14-2. configuration of input selection block p1c3/ad5 p1c2/ad4 p0d3/ad3 p0d2/ad2 p0d1/ad1 p0d0/ad0 selector each i/o port adcch2 adcch1 adcch0 compare block v adcin
195 m pd17704, 17705, 17707, 17708, 17709 figure 14-3. configuration of a/d converter channel selection register name flag symbol b 3 0 b 2 a d c c h 2 b 1 a d c c h 1 b 0 a d c c h 0 address 24h read/write r/w a/d converter channel selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 1 0 1 0 0 a/d converter not used (general-purpose input port) p0d0/ad0 pin p0d1/ad1 pin p0d2/ad2 pin p0d3/ad3 pin p1c2/ad4 pin p1c3/ad5 pin setting prohibited fixed to 0 selects pin used for a/d converter 00 0 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1 0 0 retained retained
m pd17704, 17705, 17707, 17708, 17709 196 14.3 compare voltage generation and compare blocks figure 14-4 shows the configuration of the compare voltage generation block and compare block. the compare voltage generation block switches a tap decoder according to the 8-bit data set to the a/d converter reference voltage setting register and generates 256 different of compare voltages v adcref . in other words, this block is an r-string d/a converter. the supply voltage to this r-string d/a converter is the same as the supply voltage v dd of the device. the compare block compares voltage v adcin input from a pin with compare voltage v adcref . comparison can be made in two modes, software mode and hardware mode, which can be selected by the adcmd flag. in the software mode, a compare voltage is set to the a/d converter reference voltage setting register by software, and one set compare voltage is compared with the input voltage, and the result of the comparison is detected by the adccmp flag. in the hardware mode, once comparison has been started, the hardware automatically changes the value of the a/d converter reference voltage setting register. on completion of the comparison, the value of the a/d converter reference voltage setting register is read and is loaded as an 8-bit data. figures 14-5 and 14-6 show the configuration of each flag and a/d converter reference voltage setting register. figure 14-4. configuration of compare voltage generation and compare blocks dbf tap decoder 0 1 2 254 255 v dd a/d converter reference voltage setting register (adcr) 1 2 rr r 3 2 r soft/hard, start/stop control block adcmd flag adcstt flag adccmp flag comparator - + 2 pf 1/2 v dd v adcin v adcref
197 m pd17704, 17705, 17707, 17708, 17709 figure 14-5. configuration of a/d converter mode selection register notes 1. a/d conversion under execution is stopped if 0 is written to this bit. 2. a/d operation is started in the hardware mode when 1 is written to this bit. in the software mode, operation is started as soon as data has been written (by the put instruction) to the a/d converter reference voltage setting register (adcr). name flag symbol b 3 0 b 2 a d c m d b 1 a d c s t t b 0 a d c c m p address 25h read/write r/w a/d converter mode selection power-on reser wdt&sp reser ce reser clock stop r:retained at reset 0 1 0 0 0 r v adcin < v adcref v adcin > v adcref detects result of comparison by a/d converter 00 0 r r end of conversion conversion in progress software mode note 1 hardware mode note 2 detects operating status of a/d converter in hardware mode 0 1 0 0 0 0 selects compare mode of a/d converter and starts or stops a/d converter 0 1 fixed to ?
m pd17704, 17705, 17707, 17708, 17709 198 figure 14-6. configuration of a/d converter reference voltage setting register note 0 in the hardware mode. sets or reads compare voltage v adcref of a/d converter in software mode: sets compare voltage in hardware mode: reads result of comparison data buffer dbf3 don't care dbf2 don't care name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 6 b 5 b 4 a/d converter reference volfage setting register adcr 02h power-on reset wdt&sp reset ce reset clock stop at reset 0 0 retained note retained note transfer data valid data 0 x x-0.5 256 v adcref = 0 v v adcref = v dd (v) ffh 8 bits get put
199 m pd17704, 17705, 17707, 17708, 17709 14.4 comparison timing chart 14.4.1 in software mode comparison is completed three instructions after data has been set (by the put instruction) to the a/d converter reference voltage setting register (adcr). figure 14-7 shows the timing chart. figure 14-7. timing chart of comparison by a/d converter 14.4.2 in hardware mode when the adcmd flag is set to 1, a/d conversion is started. the adcstt flag is set to 1, and comparison is completed after 17 instructions have been executed. at this time, the adcstt flag is reset to 0 after 15 instructions have been executed after the adcmd flag was set to 1. this is because execution time of two instructions is required to judge the status of the adcstt flag. for details, also refer to 14.5 using a/d converter . figure 14-8 shows the timing chart. figure 14-8. timing chart of comparison by a/d converter instruction cycle 1 0 put adcr, dbf 2 result of comparison 3 sample & hold adcstt fiag adccmp fiag comparison starts instruction cycle 1 2 1st 8th result of comparison 315 16 17 sample & hold adcstt flag reference voltage setting register a/d converter adcmd flag (=1) set. comparison starts end of comparison
m pd17704, 17705, 17707, 17708, 17709 200 14.5 using a/d converter 14.5.1 software mode the software mode is convenient for comparing one compare voltage. an example of a program in this mode is shown below. example to compare input voltage v adcin of ad0 pin with compare voltage v adcref (127.5/256 v dd ), and branch to aaa if v adcin < v adcref , or to bbb if v adcin > v adcref adcr7 flg 0.0eh.3 ; defines each bit of dbf as adcr data setting flag adcr6 flg 0.0eh.2 adcr5 flg 0.0eh.1 adcr4 flg 0.0eh.0 adcr3 flg 0.0eh.3 adcr2 flg 0.0eh.2 adcr1 flg 0.0eh.1 adcr0 flg 0.0eh.0 bank15 initflg not p0dpld3, not p0dpld2, not p0dpld1, p0dpld0 ; disconnects pull-down resistor of p0d0 pin bank0 initflg not adcch2, not adcch1, adcch0 ; selects ad0 pin for a/d converter clr1 adcmd ; sets software mode initflg adcr7, not adcr6, not adcr5, not adcr4 ; initflg not adcr3, not adcr2, not adcr1, not adcr0 ; put adcr, dbf ; sets compare voltage v adcref nop ; waits for duration of three instructions nop ; nop ; skt1 adccmp ; judges result of comparison br aaa br bbb 14.5.2 hardware mode here is a program example: example to detect the value of analog input roltage v adcin of ad0 pin. bank15 initflg not p0dpld3, not p0dpld2, not p0dpld1, p0dpld0 ; disconnects pull-down resistor of p0d0 pin bank0 initflg not adcch2, not adcch1, adcch0 ; selects ad0 pin for a/d converter set1 adcmd ; sets hardware mode and starts conversion loop: skt1 adcstt ; detects end of a/d conversion ; embedded macro instruction ;peek wr, .mf. adcstt shr4 and 0fh ;skt1 wr,#.df.adcstt and 0fh br loop ; conversion in progress get dbf,adcr ; stores result of conversion to dbf
201 m pd17704, 17705, 17707, 17708, 17709 14.6 cautions on using a/d converter 14.6.1 cautions on selecting a/d converter pin when one of the p0d0/ad0 through p0d3/ad3, p1c2/ad4, and p1c3/ad5 pins is selected, the other five pins are forcibly set in the input port mode. the p0d0/ad0 through p0d3/ad3 pins can be connected to a pull- down resistor if so specified by the p0dpl0 through p0dpld3 flags in bank 15. to use the p0d0/ad0 through p0d3/ad3 pins for the a/d converter, therefore, disconnect their pull-down resistors to correctly detect an external input analog voltage. 14.7 status at reset 14.7.1 at power-on reset all the p0d0/ad0 through p0d3/ad3, p1c2/ad4, and p1c3/ad5 pins are set in the general-purpose input port mode. the p0d0 through p0d3 pins are connected with a pull-down resistor. 14.7.2 at wdt&sp reset all the p0d0/ad0 through p0d3/ad3, p1c2/ad4, and p1c3/ad5 pins are set in the general-purpose input port mode. the p0d0 through p0d3 pins are connected with a pull-down resistor. 14.7.3 at ce reset the status of the pin selected for the a/d converter is retained as is. the previous status of the pull-down resistor of the p0d0 through p0d3 pins is retained. 14.7.4 on execution of clock stop instruction the status of the pin selected for the a/d converter is retained as is. the previous status of the pull-down resistor of the p0d0 through p0d3 pins is retained. 14.7.5 in halt status the status of the pin selected for the a/d converter is retained as is. the previous status of the pull-down resistor of the p0d0 through p0d3 pins is retained.
202 m pd17704, 17705, 17707, 17708, 17709 15. d/a converter (pwm mode) 15.1 outline of d/a converter figure 15-1 outlines the d/a converter. the d/a converter outputs a signal whose duty factor is varied by means of pwm (pulse width modulation). by connecting an external lowpass filter to the d/a converter, a digital signal can be converted into an analog signal. each pin of the d/a converter can output a variable-duty signal independently of the others. whether an 8-bit counter or 9-bit counter is used for the d/a converter can be specified by software. when the 8-bit counter is selected, two output frequencies, 4.4 khz and 440 hz can be selected, and the duty factor of the output signal can be varied in 256 steps. when the 9-bit counter is selected, two output frequencies, 2.2 khz and 220 hz, can be selected, and the duty factor can be varied in 512 steps. when the d/a converter is not used, it can be used as timer 3, which counts the basic clock (1.125 or 0.1125 mhz) with an 8-bit counter. for the details of timer 3, refer to 13. timer 3 . figure 15-1. outline of d/a converter remarks 1. pwm2sel through pwm0sel (bits 2 through 0 of pwm/general-purpose port pin function selection register: refer to figure 15-4 ) select a general-purpose output port of d/a converter. 2. pwmbit (bit 2 of pwm clock selection register: refer to figure 15-2 ) selects the number of bits (8 or 9 bits) of the pwm counter. 3. pwmck (bit 0 of pwm clock selection register: refer to figure 15-2 ) selects the output frequency of pwm timer. 4. tm3sel (bit 3 of timer 3 control register: refer to figure 15-5 ) selects timer 3 or d/a converter. 5. tm3res (bit 0 of timer 3 control register: refer to figure 15-5 ) controls resetting of timer 3 counter. p1b0/pwm0 p1b1/pwm1 p1b2/pwm2 pwm0sel flag dbf dbf dbf multiplexed with timer 3 duty setting block tm3sel flag tm3res flag res f pwm irqtm3 comparator comparator comparator pwmbit pwmck clock generation block 9-bit or 8-bit counter pwm data register 0 (pwmr0) pwm data register 1 (pwmr1) pwm data register 2 (pwmr2) output selection block output selection block output selection block pwm1sel flag pwm2sel flag
203 m pd17704, 17705, 17707, 17708, 17709 15.2 pwm clock selection register the pwm clock selection register specifies whether the pwm counter is used as an 8-bit counter or 9-bit counter when the d/a converter is used for pwm output. figure 15-2 shows the configuration of the pwm clock selection register. figure 15-2. configuration of pwm clock selection register name flag symbol b 3 0 b 2 p w m b i t b 1 0 b 0 p w m c k address 26h read/write r/w pwm clock selection power-on reset wdt&sp reset ce reset clock stop r: retained at reset 0 1 0 0 r 0 4.4 khz (8 bits) /2.2 khz (9 bits) 440 hz (8 bits) /220 hz (9 bits) selects output frequency of timer 3 00 0 r 0 fixed to 0 fixed to 0 8 bits 9 bits 0 selects number of bits of pwm counter 0 1
204 m pd17704, 17705, 17707, 17708, 17709 15.3 pwm output selection block the output selection block specifies whether each output pin of the d/a converter is used for the d/a converter or as a general-purpose output port, by using the pwm2sel through pwm0sel flags of the pwm/general-purpose port pin function selection register. figure 15-3 shows the configuration of the output selection block, and figure 15-4 shows the configuration of the pwm/general-purpose port pin function selection register. each pin can be changed between the d/a converter mode and general-purpose output port mode independently of the others. because each output pin is an n-ch open-drain output pin, an external pull-up resistor is necessary. when the d/a converter is used as timer 3, the p1b2/pwm2 through p1b0/pwm0 pins are automatically set in the general-purpose output port mode, regardless of the values set to the pwm2sel through pwm0sel flags. figure 15-3. configuration of output selection block pwm2sel through pwm0sel flags tm3sel comparator output output latch 1 0 each output pin
205 m pd17704, 17705, 17707, 17708, 17709 figure 15-4. configuration of pwm/general-purpose port pin function selection register name flag symbol b 3 0 b 2 p w m 2 s e l b 1 p w m 1 s e l b 0 p w m 0 s e l address 27h read/write r/w pwm/general-purpose port pin function selection power-on reset wdt&sp reset ce reset clock stop retained at reset 0 1 0 0 0 general-purpose output port d/a converter selects function of p1b0/pwm0 pin 00 0 0 general-purpose output port d/a converter general-purpose output port d/a converter selects function of p1b1/pwm1 pin 0 1 0 0 0 selects function of p1b2/pwm2 pin 0 1 fixed to 0
206 m pd17704, 17705, 17707, 17708, 17709 figure 15-5. configuration of timer 3 control register name flag symbol b 3 t m 3 s e l b 2 0 b 1 t m 3 e n b 0 t m 3 r e s address 28h read/write r/w timer 3 control 0 1 does not change resets resets counter stops starts fixed to 0 starts or stops counter 0 1 d/a converter (pwm output) timer 3 selects timer 3 or d/a converter 0 1 power-on reset wdt&sp reset ce reset clock stop r: retained at reset 0 0 0 0 0 0 r 0 0 0 0 retained
207 m pd17704, 17705, 17707, 17708, 17709 15.4 duty setting block 15.4.1 pwm duty with 8-bit counter selected the duty setting block compares the value set to each pwm data register (pwmr2 to pwmr0) with the value of the basic clock counted by each 8-bit counter. if the value of the pwm data register is greater, the block outputs a high level. if the value of the pwm data register is less, it outputs a low level. where the value set to the pwm data register is x, therefore, the duty factor can be calculated by the following expression. duty: d = x + 0.25 100% 256 remark 0.25 is an offset, and a high level is output even where x = 0. data is set to each pwm data register for each pin via data buffer (dbf). however, the same basic clock, pwm counter, and output frequency must be selected for each pin. this means that each pin cannot output a duty factor of a different cycle independently of the others. because the basic clock frequency is 1.125 or 0.1125 mhz, the frequency and cycle of the output signal can be calculated as follows. (1) where output frequency is 4.4 khz and basic clock frequency is 1.125 mhz frequency: f = 1.125 mhz = 4.3945 khz 256 cycle: t = 256 = 227.56 m s 1.125 mhz (2) where output frequency is 440 hz and basic clock frequency is 0.1125 mhz frequency: f = 0.1125 mhz = 439.45 hz 256 cycle: t = 256 = 2.2756 ms 0.1125 mhz because the duty setting register of the pwm data registers and timer 3 modulo register are the same register, they cannot be used at the same time. when timer 3 is used, pwm data registers 1 and 0 can be used as 8-bit data latches.
208 m pd17704, 17705, 17707, 17708, 17709 figure 15-6. configuration of pwm data registers (with 8-bit counter selected) note this register is multiplexed with timer 3 modulo register. sets pwm output duty of each pin data buffer dbf3 dbf2 name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 8 0 b 9 0 b 10 0 b 11 0 b 12 0 b 13 0 b 14 0 b 15 0 b 6 b 5 b 4 pwm data register 2 note pwmr2 46h power-on reset wdt&sp reset ce reset clock stop at reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 retained transfer data valid data 0 x duty: d = fixed to 0 ffh 16 bits get put name symbol address bit data b 3 b 2 b 1 b 0 b 7 b 8 0 b 9 0 b 10 0 b 11 0 b 12 0 b 13 0 b 14 0 b 15 0 b 6 b 5 b 4 pwm data register 1 pwmr1 45h valid data get put name symbol address bit data b 3 b 2 b 1 b 0 b 7 b 8 0 b 9 0 b 10 0 b 11 0 b 12 0 b 13 0 b 14 0 b 15 0 b 6 b 5 b 4 pwm data register 0 pwmr0 44h valid data get put x+0.25 256 100 %
209 m pd17704, 17705, 17707, 17708, 17709 15.4.2 pwm duty with 9-bit counter selected the duty setting block compares the value set to each pwm data register (pwmr2 to pwmr0) with the value of the basic clock counted by each 9-bit counter. if the value of the pwm data register is greater, the block outputs a high level. if the value of the pwm data register is less, it outputs a low level. where the value set to the pwm data register is x, therefore, the duty factor can be calculated by the following expression. duty: d = x + 0.25 100% 512 remark 0.25 is an offset, and a high level is output even where x = 0. data is set to each pwm data register for each pin via data buffer (dbf). however, the same basic clock, pwm counter, and output frequency must be selected for each pin. this means that each pin cannot output a duty factor of a different cycle independently of the others. because the basic clock frequency is 1.125 or 0.1125 mhz, the frequency and cycle of the output signal can be calculated as follows. (1) where output frequency is 2.2 khz and basic clock frequency is 1.125 mhz frequency: f = 1.125 mhz = 2.197 khz 512 cycle: t = 512 = 455.11 m s 1.125 mhz (2) where output frequency is 220 hz and basic clock frequency is 0.1125 mhz frequency: f = 0.1125 mhz = 219.73 hz 512 cycle: t = 512 = 4.5511 ms 0.1125 mhz because the duty setting register of the pwm data registers and timer 3 modulo register are the same register, they cannot be used at the same time. when timer 3 is used, pwm data registers 1 and 0 can be used as 8-bit data latches.
210 m pd17704, 17705, 17707, 17708, 17709 figure 15-7. configuration of pwm data registers (with 9-bit counter selected) note this register is multiplexed with timer 3 modulo register. sets pwm output duty of each pin data buffer dbf3 dbf2 name symbol address bit data dbf1 dbf0 b 3 b 2 b 1 b 0 b 7 b 8 b 9 0 b 10 0 b 11 0 b 12 0 b 13 0 b 14 0 b 15 0 b 6 b 5 b 4 pwm data register 2 note pwmr2 46h power-on reset wdt&sp reset ce reset clock stop at reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 retained transfer data valid data 0 x duty: d = fixed to 0 1ffh 16 bits get put name symbol address bit data b 3 b 2 b 1 b 0 b 7 b 8 b 9 0 b 10 0 b 11 0 b 12 0 b 13 0 b 14 0 b 15 0 b 6 b 5 b 4 pwm data register 1 pwmr1 45h valid data get put name symbol address bit data b 3 b 2 b 1 b 0 b 7 b 8 b 9 0 b 10 0 b 11 0 b 12 0 b 13 0 b 14 0 b 15 0 b 6 b 5 b 4 pwm data register 0 pwmr0 44h valid data get put x+0.25 512 100 %
211 m pd17704, 17705, 17707, 17708, 17709 15.5 clock generation block the clock generation block outputs a basic clock to set the duty factor of each output signal. two output frequencies, 1.125 mhz and 112.5 khz, can be selected. 15.6 d/a converter output wave (1) shows the relationship between the duty factor and output wave. (2) shows the output wave of each pin. each output pin has a phase different from the others. (1) duty and output wave (a) with 8-bit counter and 4.4 khz selected (b) with 8-bit counter and 440 hz selected 222 ns x = 0 x = 1 x = 2 x = 255 667 ns 888 ns 888 ns 227.56 s m 2.22 s x = 0 x = 1 x = 2 x = 255 6.67 s 8.88 s 8.88 s 2.2756 ms m mm m
212 m pd17704, 17705, 17707, 17708, 17709 (c) with 9-bit counter and 2.2 khz selected (d) with 9-bit counter and 220 hz selected (2) each pin and output wave (a) with 8-bit counter and 4.4 khz selected 222 ns x = 0 x = 1 x = 2 x = 511 667 ns 888 ns 888 ns 455.11 s m 2.22 s x = 0 x = 1 x = 2 x = 511 6.67 s 8.88 s 8.88 s 4.5511 ms mmm m 222 ns pwm0 (x = 0) pwm1 (x = 0) pwm2 (x = 0) 222 ns 222 ns 227.56 s 227.56 s 227.56 s m m m
213 m pd17704, 17705, 17707, 17708, 17709 (b) with 8-bit counter and 440 hz selected (c) with 9-bit counter and 2.2 khz selected (d) with 9-bit counter and 220 hz selected 2.22 s pwm0 (x = 0) pwm1 (x = 0) pwm2 (x = 0) 2.22 s 2.22 s 2.2756 ms 2.2756 ms 2.2756 ms m m m 222 ns pwm0 (x = 0) pwm1 (x = 0) pwm2 (x = 0) 222 ns 222 ns 455.11 s 455.11 s 455.11 s m m m 2.22 s pwm0 (x = 0) pwm1 (x = 0) pwm2 (x = 0) 2.22 s 2.22 s 4.5511 ms 4.5511 ms 4.5511 ms m m m
214 m pd17704, 17705, 17707, 17708, 17709 15.7 example of using d/a converter an example of a program using the d/a converter is shown below. example this program increments the duty factor of the pwm1 pin every 1 second. pwm1data dat 0000h initial: initflg not pwm2sel, not pwm1sel, not pwm0sel ; (general-purpose port), (general-purpose port), (general-purpose port) initflg pwmbit , not pwmck ; (9-bit counter), (1.125 mhz) loop0: bank1 clr1 p1b1 bank0 clr1 tm3sel ; selects d/a converter mov dbf2, #pwm1data shr 8 and 0fh mov dbf1, #pwm1data shr 4 and 0fh mov dbf0, #pwm1data and 0fh set1 pwm1sel ; sets pwm1/p1b1 pin in pwm output port mode loop1: ; duty: 0.25/512 to 511.25/512 (pwm output) put pwm1r, dbf get2 tm3res, tm3en ; resets and starts counter waits for 1 second get dbf, pwm1r add dbf0, #1 addc dbf1, #0 addc dbf2, #1 skge dbf2, #2 br loop1 loop2: ; port outputs high level bank1 set1 p1b1 bank0 clr1 pwm1sel ; sets pwm1/p1b1 pin in general-purpose output port mode waits for 1 second br loop0
215 m pd17704, 17705, 17707, 17708, 17709 15.8 status at reset 15.8.1 at power-on reset the p1b0/pwm0 through p1b2/pwm2 pins are set in the general-purpose output port mode. the output value is low level. the value of each pwm data register (including the timer 3 modulo register) is 1ffh. 15.8.2 at wdt&sp reset the p1b0/pwm0 through p1b2/pwm2 pins are set in the general-purpose output port mode. the output value is low level. the value of each pwm data register (including the timer 3 modulo register) is 1ffh. 15.8.3 at ce reset the p1b0/pwm2 through p1b2/pwm2 pins retain the previous status. that is, if the d/a converter is being used, the pwm output is retained as is. if timer 3 is being used, counting continues. 15.8.4 on execution of clock stop instruction the p1b0/pwm0 through p1b2/pwm2 pins are set in the general-purpose output port mode. the output value is the previous contents of the output latch. the value of each pwm data register (including the timer 3 modulo register) is 1ffh. 15.8.5 in halt status the p1b0/pwm0 through p1b2/pwm2 pins retain the previous status. that is, if the d/a converter is being used, the pwm output is retained as is. if timer 3 is being used, counting continues.
216 m pd17704, 17705, 17707, 17708, 17709 16. serial interfaces 16.1 outline of serial interfaces figure 16-1 outlines the serial interfaces. table 16-1 classifies the serial interfaces and shows their communication modes. as shown in figure 16-1, two serial interfaces, 0 (sio0) and 1 (sio1), are available. serial interfaces 0 and 1 can be used at the same time. serial interface 0 can be used in two modes: 2-wire and 3-wire modes. in the 2-wire mode, two pins, sda and scl, are used. in the 3-wire mode, three pins, sck0, so0, and si0, are used. in the 2-wire mode, two communication modes, i 2 c bus and serial i/o modes, can be selected. serial interface 1 can be used only in 3-wire mode, and uses three pins, sck1, so1, and si1. the communication mode is the serial i/o mode. figure 16-1. outline of serial interfaces serial interface 0 4.5 mhz presettable shift register 0 (sio0sfr) i/o control clock control block sda/p0a3 scl/p0a2 sck0/p0a1 so0/p0a0 si0/p0b3 interrupt control block irqsio0 flag serial interface 1 4.5 mhz presettable shift register 1 (sio1sfr) i/o control clock control block sck1/p0b2 so1/p0b1 si1/p0b0 irqsio1 flag
217 m pd17704, 17705, 17707, 17708, 17709 table 16-1. classification and communication modes of serial interfaces number of channel communication communication mode pins used lines serial interface 0 2 lines (2-wire) i 2 c bus p0a3/sda serial i/o p0a2/scl 3 lines (3-wire) serial i/o p0a1/sck0 p0a0/so0 p0b3/si0 serial interface 1 3 lines (3-wire) serial i/o p0b2/sck1 p0b1/so1 p0b0/si1 16.2 serial interface 0 16.2.1 outline of serial interface 0 figure 16-2 outlines the serial interface 0. serial interface 0 can be used in 2-wire i 2 c bus or serial i/o mode, or 3-wire serial i/o mode. figure 16-2. outline of serial interface 0 scl/p0a2 sio0ch flag sb flag sio0ms flag sio0ch flag sb flag sio0tx flag clock i/o control block data i/o control block sio0ck0, 1 flag wait signal sio0wstt flag sio0wrq0, 1 flag sio0nwt flag 4.5 mhz sio0imd0, 1 flag interrupt control block wait control block clock control block clock counter start/stop detection block sio0sf8, 9 flag count values 8, 9 sbstt, sbbsy flag serial date acknowledge control block presettable shift register 0 (sio0sfr) ack sback flag sda/p0a3 so0/p0a0 si0/p0b3 sck0/p0a1 out in
218 m pd17704, 17705, 17707, 17708, 17709 remarks 1. sio0ch and sb (bits 3 and 2 of serial i/o0 mode selection register: refer to figure 16-3 ) select the mode of serial i/o0. 2. sio0ms (bit 1 of serial i/o0 mode selection register: refer to figure 16-3 ) select a master or slave. 3. sio0tx (bit 0 of serial i/o0 mode selection register: figure 16-3 ) selects reception or transmission. 4. sio0ck1 and sio0ck0 (bits 1 and 0 of serial i/o0 clock selection register: refer to figure 16-4 ) select an internal shift clock frequency. 5. sio0wrq1 and sio0wrq0 (bits 1 and 0 of serial i/o0 wait control register: refer to figure 16-7 ) set wait conditions for communication. 6. sio0nwt (bit 2 of serial i/o0 wait control register: refer to figure 16-7 ) starts communication. 7. sio0sf9 and sio0sf8 (bits 2 and 3 of serial i/o0 status detection register: refer to figure 16-5 ) detect a clock counter. 8. sbstt and sbbsy (bits 1 and 0 of serial i/o0 status detection register: refer to figure 16-5 ) detect the start and stop conditions, and clock counter in the i 2 c bus mode. 9. sio0imd1 and sio0imd0 (bits 1 and 0 of serial i/o0 interrupt mode selection register: refer to figure 16-9 ) set interrupt timing. 10. sback (bit 3 of serial i/o0 wait control register: refer to figure 16-7 ) reads or sets acknowledge data. 11. sio0wstt (bit 0 of serial i/o0 wait status judge register: refer to figure 16-8 ) detects serial communication status. 16.2.2 clock i/o control block and data i/o control block the clock i/o control block and data i/o control block control the communication mode (i 2 c bus or serial i/o mode), the number of pins used (2-wire or 3-wire mode), and transmission or reception operation of serial interface 0. the 2-wire or 3-wire mode, and i 2 c bus or serial i/o mode are selected by using the sio0ch and sb flags. the sio0ms flag selects the internal clock (master) or external clock (slave) operation, and the sio0tx flag selects reception (rx) or transmission (tx). each flag is allocated to the serial i/o0 mode selection register. figure 16-3 shows the configuration of the serial i/o0 mode selection register. table 16-2 shows the set status of each pin. as shown in this table, flags that set the input or output mode of each pin must also be manipulated in addition to the control flags of the serial interface, in order to set each pin.
219 m pd17704, 17705, 17707, 17708, 17709 figure 16-3. configuration of serial i/o0 mode selection register name flag symbol b 3 s i o 0 c h b 2 s b b 1 s i o 0 m s b 0 s i o 0 t x address 0fh read/write r/w serial i/o0 mode selsction power-on reset wdt&sp reset ce reset clock stop at reset 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 serial input ( hi-z ) : rx serial output : tx general-purpose port serial output : tx 2-wire ( sda/p0a3 pin ) 3-wire ( so0/p0a0 pin ) sets serial i/o of sda/p0a3 pin ( 2-wire ) and so0/p0a0 pin ( 3-wire ) ( selects reception rx or transmission tx ) 0 1 0 1 0 1 i 2 c bus mode serial i/o mode sets direction of shift clock slave operation ( external clock input ) master operation ( internal clock output ) external clock input internal clock output serial i/o0 not used i 2 c bus mode 2-wire serial i/o mode 3-wire serial i/o mode sets mode of serial i/o0
220 m pd17704, 17705, 17707, 17708, 17709 table 16-2. status of each pin set by control flag serial input general-purpose output port general-purpose output port general-purpose i/o port general-purpose i/o port general-purpose i/o port general-purpose i/o port general-purpose i/o port general-purpose i/o port general-purpose i/o port general-purpose i/o port serial output serial input general-purpose output port serial input general-purpose output port general-purpose input port general-purpose input port general-purpose output port serial output general-purpose output port serial output external clock internal clock general-purpose output port external clock internal clock general-purpose output port external clock internal clock 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 p 0 a b i o 3 s i o 0 c h s i o 0 m s s i o 0 t x s b p 0 a b i o 2 p 0 a b i o 1 p 0 a b i o 0 p 0 a b i o 0 pin setting status pin name pin each flag communication mode clock direction serial i/o 00 p0a3/sda p0a2/scl p0a1/sck0 p0a0/so0 p0b3/si0 p0a3/sda p0a2/scl p0a1/sck0 p0a0/so0 p0b3/si0 p0a0/so0 p0b3/si0 p0a0-p0a3, p0b3 p0a3/sda p0a2/scl p0a1/sck0 input (reception) output (transmission) input (reception) output (transmission) general-purpose port output (transmission) external (slave) (internal) (master) external (slave) internal (master) external (slave) internal (master) 2-wire serial i/o i 2 c bus 3-wire serial i/o not used as serial i/o0
221 m pd17704, 17705, 17707, 17708, 17709 16.2.3 clock control block the clock control block controls generation of a clock when the internal clock is used (master operation) and clock output timing. the frequency f sc of the internal clock is set by the sio0ck1 and sio0ck0 flags of the serial i/o0 clock selection register. figure 16-4 shows the configuration of the serial i/o0 clock selection register. the shift clock output from the clock control block is valid only for the master operation (sio0ms flag = 1). for the clock generation timing, refer to the description of each communication mode . figure 16-4. configuration of serial i/o0 clock selection register name flag symbol b 3 0 b 2 s b m d b 1 s i o 0 c k 1 b 0 s i o 0 c k 0 address 0bh read/write r/w serial i/o0 clock selection power-on reset wdt&sp reset ce reset clock stop at reset 00 0 0 0 0 0 0 0 0 0 0 0 93.75 khz 375.00 khz 281.25 khz 46.875 khz selects internal shift clock frequency f sc of serial interface 0 continues processing slave reception mode is set automatically if acknowledge signal is not received (fixed to 1 when serial i/o is selected) selects operation mode during slave transmission of i 2 c bus fixed to 0 0 1 0 0 1 1 0 1 0 1
222 m pd17704, 17705, 17707, 17708, 17709 16.2.4 clock counter and start/stop detection block the clock counter is a wrap-around counter that counts the rising edges of the clock. because this counter directly reads the status of the clock pin, whether the clock is an internal clock or external clock cannot be identified. the contents of the clock counter can be detected via the sio0sf8 and sio0sf9 flags of the serial i/o0 status detection register, but cannot be directly read by program. the start/stop detection block detects the start and stop conditions when the i 2 c bus mode is used. the start and stop conditions are detected by the sbstt and sbbsy flags of the serial i/o0 status detection register. figure 18-5 shows the configuration of the serial i/o0 status detection register. for the operation and timing chart of the clock counter, refer to the description of each communication mode .
223 m pd17704, 17705, 17707, 17708, 17709 figure 16-5. configuration of serial i/o0 status detection register name flag symbol b 3 s i o 0 s f 8 b 2 s i o 0 s f 9 b 1 s b s t t b 0 s b b s y address 0dh read/write r serial i/o0 status detection power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 detects stop condition detects start condition detects start /stop condition of i 2 c bus mode 0 1 0 1 0 1 i 2 c bus mode serial i/o mode retains 0 detects rising of clock when value of clock counter is 9 detects start condition detects start condition and clock counter in i 2 c bus mode i 2 c bus mode serial i/o mode retains 0 detects rising of clock when value of clock counter is next to 9 value of clock counter is 9 detects clock counter i 2 c bus mode serial i/o mode retains 0 detects rising of clock when value of clock counter is next to 8 value of clock counter is 8 detects clock counter i 2 c bus mode serial i/o mode
224 m pd17704, 17705, 17707, 17708, 17709 16.2.5 presettable shift register 0 presettable shift register 0 is an 8-bit shift register that writes serial out data and reads serial in data. this register writes or reads data via data buffer. it outputs the contents of the most significant bit (msb) from the serial data i/o pin in synchronization with the falling edge of the shift clock (during transmission operation), and reads data to the least significant bit (lsb) in synchronization with the rising edge of the serial clock. figure 16-6 shows the configuration of the presettable shift register 0. figure 16-6. configuration of presettable shift register 0 note data may be destroyed if the put or get instruction is executed during serial communication. for details, refer to 16.2.10 causions on setting and reading data . name b 3 b 2 b 1 symbol peripheral register b 0 l s b 03h sets serial out data and reads serial in data d7 d6 d5 d4 d3 d2 d1 d0 serial out serial in peripheral register sio0sfr b 7 m s b b 6 b 5 b 4 presettable shift register 0 valid data d7 d6 d5 d4 d3 d2 d1 d0 dbf3 data buffer don't care transfer data dbf2 don't care dbf1 dbf0 get note 8 put note
225 m pd17704, 17705, 17707, 17708, 17709 16.2.6 wait control block and acknowledge control block the wait control block keeps communication waiting or releases communication from the wait status. the condition under which communication is kept waiting is set by the sio0wrq0 and 1 flags (bits 0 and 1 of serial i/o0 wait control register). serial communication is started when the sio0nwt flag (bit 2 of serial i/o0 wait control register) is set (released from the wait status). the communication status can be detected by the sio0nwt flag. when 0 is written to the sio0nwt flag while communication is released from the wait status, the wait status is set. this is called forced wait status. the acknowledge control block outputs and detects an acknowledge signal in the i 2 c bus mode. an acknowledge signal is set and read by the sback flag (bit 3 of serial i/o0 wait control register). figure 16-7 shows the configuration of the serial i/o0 wait control register. figure 16-8 shows the configuration of the serial i/o0 wait status judge register.
226 m pd17704, 17705, 17707, 17708, 17709 figure 16-7. configuration of serial i/o0 wait control register name flag symbol b 3 s b a c k b 2 s i o 0 n w t b 1 s i o 0 w r q 1 b 0 s i o 0 w r q 0 address 0eh read/write r/w serial i/o0 wait control power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 no wait data wait acknowledge wait address wait does not wait sets wait condition 0 1 0 1 i 2 c bus mode name serial i/o mode waits at falling edge of shift clocks when value of clock counter is 8 waits at falling edge of shift clock when value of clock counter is 9 waits at falling edge of clock when value of clock counter is 8 after detection of start condition wait at rising edge of shift clock when value of clock counter is 8 setting prohibited forced wait releases wait status (serial communication starts) sets wait and detects wait status when flag is written when flag is read waits under condition of sio0wrq0 and 1 flags serial communication in progress reception (sio0tx = 0) transmission (sio0tx = 1) sets and detects acknowledge signal in i 2 c bus mode i 2 c bus mode serial i/o mode retains 0 detects acknowledge of slave (acknowledge is 0 ) detects acknowledge of slave (acknowledge is 1 ) outputs 0 as acknowledge outputs 1 as acknowledge
227 m pd17704, 17705, 17707, 17708, 17709 figure 16-8. configuration of serial i/o0 wait status judge register caution if a slave outputs a wait request while the master is operating, 0 is detected on the sio0wstt flag. the sio0nwt flag retains the status of 1. name flag symbol b 3 0 b 2 0 b 1 0 b 0 s i o 0 w s t t address 0ah read/write r serial i/o0 wait status judge power-on reset wdt&sp reset ce reset clock stop at reset 0000 0 0 0 waiting or requesting wait by slave serial communication in progress fixed to 0 detects serial communication status 0 1
228 m pd17704, 17705, 17707, 17708, 17709 16.2.7 interrupt control block the interrupt control block sets a condition under which an interrupt request is issued by the serial i/o0 interrupt mode selection register. when the interrupt request issuance condition is satisfied, the irqsio0 flag is set. change the interrupt request issuance condition while communication is in the wait status. if it is changed after communication has been released from the wait status, an interrupt request may be issued as soon as the condition has been changed. figure 16-9 shows the configuration of the serial i/o0 interrupt mode selection register. figure 16-9. configuration of serial i/o0 interrupt mode selection register notes 1. an interrupt request is issued if this mode is set when the value of the clock counter is 7. 2. an interrupt request is issued if this mode is set when the value of the clock counter is 8. 3. an interrupt request is issued if this mode is set when the sbstt flag = 1 and the value of the clock counter is 7. 4. an interrupt request is issued if this mode is set after the stop condition has been issued. name flag symbol b 3 0 b 2 0 b 1 s i o 0 i m d 1 b 0 s i o 0 i m d 0 address 0ch read/write r/w serial i/o0 interrupt mode selection power-on reset wdt & sp reset ce reset clock stop at reset 000 0 0 0 0 0 0 0 rising edge of shift clock when value of clock counter reaches 7 rising edge of shift clock when value of clock counter reaches 8 rising edge of shift clock when value of clock counter reaches 7 after detection of start condition note 3 when stop condition is detected note 4 rising edge of shift clock when value of clock counter reaches 7 note 1 rising edge of shift clock when value of clock counter reaches 8 note 2 interrupt request is not issued sets interrupt request issuance condition fixed to 0 0 0 1 1 0 1 0 1 i 2 c bus mode serial i/o mode
229 m pd17704, 17705, 17707, 17708, 17709 16.2.8 i 2 c bus mode (1) outline of i 2 c bus mode in the i 2 c bus mode, communication is carried out with two pins, scl and sda. the features of the i 2 c bus mode are as follows. ? communication can be controlled under the start/stop conditions and by the acknowledge signal for the ninth clock. ? communication can be kept waiting by externally fixing the clock to low level with an n-ch open-drain pin. (2) timing chart figure 16-10 shows the timing chart. figure 16-10. timing chart in i 2 c bus mode <1> initial status (general-purpose input port) <2> generates start condition by general-purpose i/o port <3> sets transmission status of master <4> releases wait <5> wait timing when data wait status is set <6> wait timing when acknowledge wait status is set <7> sets general-purpose i/o port (releases serial operation mode) <8> generates stop condition by general-purpose i/o port <9> issues interrupt request when value of clock counter first reaches 7 after detection of start condition <10> issues interrupt request when value of clock counter reaches 7 <11> issues interrupt request when value of clock counter reaches 8 <12> issues interrupt request after stop condition is detected clock counter serial data shift clock sio0nwt sio0wstt sio0sf8 sio0sf9 sbstt sbbsy stop condition <1> <2> <3> <4> 1 d7 d6 d5 d1 d0 ack 2 3 789 int 90 8 7 6 2 1 0 <9> <10> <5> <11> <6> <7> <8> <12> start condition
230 m pd17704, 17705, 17707, 17708, 17709 (3) operation of clock counter the value of the clock counter is incremented from the initial value 0 each time the rising of the clock pin has been detected. in the i 2 c bus mode, the value of the clock counter returns to 0 after it has reached 9, and the clock counter continues counting. in the serial i/o mode, the value of the clock counter returns to 0 after it has reached 8, and the clock counter continues counting. the clock counter is also reset in the following cases. ? at reset (power-on reset, wdt&sp reset, ce reset) ? on execution of clock stop instruction ? on detection of start condition ? if communication mode is changed from i 2 c bus mode to 2-wire or 3-wire serial i/o mode (4) wait operation and cautions when the wait status is released, serial data is output (during transmission operation), and the wait status is kept released until a condition (wait condition) set by the sio0wrq0 and 1 flags is satisfied. when the wait condition is satisfied, the shift clock pin is made low, and the operations of the clock counter and presettable shift register 0 are stopped. if the forced wait status is specified while the wait status is released, the forced wait status is set at the falling of the clock next to the one at which 0 has been written to the sio0nwt flag. nothing is changed even if the wait status is released again after the wait status has been released once. if the forced wait status is set in the wait status, one pulse of the shift clock is output. in the i 2 c bus mode, do not set data wait conditions (siowrq0 = 1, wio0wrq1 = 0) successively. this is because, if the data wait condition is set two times in succession and the wait status is released, the wait status is set as soon as the wait status has been released the second time. while the device is operating as the master and if the level of the shift clock output pin is forcibly made low externally while the pin outputs a high level (this is called a wait request by slave), the master is placed in the wait status. if this happens, the master resumes its operation when the wait request by the slave has been cleared. (5) interrupt request issuance timing interrupt request issuance timing can be selected by the sio0imd0 and 1 flags. (6) acknowledge block and its operation the acknowledge block operates only in the i 2 c bus mode. this block is used to output an acknowledge signal during a reception operation, or to detect an acknowledge signal during a transmission operation. during reception, the content of the sback flag is output to the serial data pin at the falling edge of the shift clock when the value of the clock counter is 8. once data has been set to the sback flag during reception, the value of the data is retained. during transmission, the status of the serial data pin is read to the sback flag at the rising edge of the shift clock when the value of the clock counter reaches 9 figure 16-11 shows the acknowledge signal output and input operations. during reception, set the acknowledge signal (setting of the sback flag) as soon as the wait status has been released (by setting the sio0nwt flag).
231 m pd17704, 17705, 17707, 17708, 17709 this is because, even if only the sback flag is set, the sio0nwt flag is also set because it is in the register at the same address. if the wait status is set at this time, the wait status is released and one pulse of the shift clock is output. figure 16-11. acknowledge output and input operations data input data hi-z (d1) hi-z (d0) sback output hi-z shift clock 7 8 9 acknowledge output at this time, wait status must be released at the same time. data output data d1 output d0 output ack at reception side shift clock 7 8 9 acknowledge input (a) during reception (b) during transmission
232 m pd17704, 17705, 17707, 17708, 17709 (7) shift clock generation timing in i 2 c bus mode (a) on releasing wait status from initial status the initial status is the point where the master operation in the i 2 c bus mode is selected. in the wait status, a low level is output to the shift clock pin. figure 16-12. shift clock generation timing in i 2 c bus mode (1/5) wait period 1/f sc shift clock wait released initialization 1 : 1 (b) during wait operation <1> wait status under condition of sio0wrq0 and sio0wrq1 flags (normal operation) figure 16-12. shift clock generation timing in i 2 c bus mode (2/5) wait period wait released status 1/f sc shift clock wait under condition of sio0wrq1 and sio0wrq0 wait released <2> if forced wait status is set in wait status nothing is affected.
233 m pd17704, 17705, 17707, 17708, 17709 <3> if forced wait status is set after wait status has been released in this case, the wait status is set at the next falling edge of the clock after the one at which the forced wait status was set. when the forced wait status was set, however, the clock counter and presettable shift register 0 stop operating. if the forced wait status is set while the clock pin is low, the clock counter and presettable shift register 0 operate by 1 pulse. because the internal clock counter and shift register do not operate at this time, communication may not be performed normally even if the wait status is released again. figure 16-12. shift clock generation timing in i 2 c bus mode (3/5) 1/f sc wait period wait pending wait released status shift clock shift clock wait period 1/f sc wait pending wait released forced wait set by sio0nwt forced wait set by sio0nwt wait released <4> if wait status is released after wait status has been released nothing is affected. <5> if wait request is made by slave after wait status has been released at this time, the clock is output 0 to 3.3 m s after the wait request by the slave has been cleared. the value of t in the figure below is as follows: f sc t 93.75 khz 666 ns 375.00 khz 222 ns 281.25 khz 222 ns 46.875 khz 666 ns
234 m pd17704, 17705, 17707, 17708, 17709 figure 16-12. shift clock generation timing in i 2 c bus mode (4/5) (c) during slave (external clock) operation when the slave operation is specified the first time after application of supply voltage v dd , the sck pin waits for input of an external clock and the output pin goes into a high-impedance state. if the scl pin is externally made low at this time, it continues outputting a low level until the wait status is released next time. figure 16-12. shift clock generation timing in i 2 c bus mode (5/5) 1/f sc wait request by slave wait released status shift clock wait request by slave cleared 0-3.3 s wait request by slave t shift clock wait request by slave cleared t m 0-3.3 s m wait period (originally, hi-z) i/o port wait released period shift clock slave is set wait released (8) start and stop conditions, and operations of sbstt and sbbsy flags the start/stop condition recognition timing is shown in figure 16-13. the sbstt and sbbsy flags operate only in the i 2 c bus mode. by detecting these flags, communication status of the other stations can be detected. these flags operate regardless of whether the device operates as the master or slave, whether it performs reception or transmission, and whether communication is in the wait status or released from the wait status. these flags are 0 in the serial i/o mode. for the operations of the sbstt and sbbsy flags, refer to figure 16-10 timing chart in i 2 c bus mode .
235 m pd17704, 17705, 17707, 17708, 17709 figure 16-13. start/stop condition recognition timing (a) start condition recognition timing sbstt serial data pin shift clock pin sbbsy l h detects falling of serial data pin about 1 s start condition is assumed if shift clock pin goes high about 1 s after serial data pin has gone low. l h h l l h m m (b) stop condition recognition timing sbstt serial data pin shift clock pin sbbsy l h detects rising of serial data pin about 1 s stop condition is assumed if shift clock pin goes high about 1 s after serial data pin has gone high. h l h l l h m m
236 m pd17704, 17705, 17707, 17708, 17709 16.2.9 serial i/o mode (1) outline of serial i/o mode in the serial i/o mode, communication is carried out by using two pins, scl and sda, or three pins, sck0, so0, and si0. (2) timing chart figure 16-14 shows the timing chart in the serial i/o mode. figure 16-14. timing chart in serial i/o mode clock counter 0 1 2 6 7 8 0 1 serial data la d7 d6 d5 d1 d0 d7 shift clock sio0nwt sio0wstt sio0sf8 sio0sf9 0 sbstt 0 sbbsy 0 <1> <2> <3> <4> 1 1 23 7 8 <5> int<6> <7> <1> initial status (general-purpose input port) <2> sets transmission status of master <3> releases wait status <4> wait timing when data wait status is set <5> releases wait status again <6> issues interrupt request when value of clock counter is 7 <7> issues interrupt request when value of clock counter is 8
237 m pd17704, 17705, 17707, 17708, 17709 (3) operation of clock counter the value of the clock counter is incremented from the initial value 0 each time the rising of the clock pin has been detected. the value of the clock counter returns to 0 after it has reached 8, and the clock counter continues counting. the clock counter is also reset in the following cases. ? at reset (power-on reset, wdt&sp reset, ce reset) ? on execution of clock stop instruction ? if data is written to serial i/o0 wait control register ? if communication mode is changed from 2-wire or 3-wire serial i/o mode to i 2 c bus mode (4) wait operation and cautions when the wait status is released, serial data is output (during transmission operation) at the falling of the next clock, and the wait status is kept released until a condition (wait condition) set by the sio0wrq0 and 1 flags is satisfied. when the wait condition is satisfied, the shift clock pin is made high, and the operations of the clock counter and presettable shift register 0 are stopped. the value of the presettable shift register 0 cannot be read correctly if it is read while the wait status is released and while the shift clock pin is high. correct data cannot be written to the presettable shift register 0 while the wait status is released and while the shift clock pin is low. if the forced wait status is specified while the wait status is released, the forced wait status is set as soon as 0 has been written to the sio0nwt flag. the clock output wave is not affected even if the wait status is released again when it has been already released once. note, however, that the clock counter is reset. (5) interrupt request issuance timing interrupt request issuance timing can be selected by the sio0imd0 and 1 flags. for details, refer to 16.2.7 interrupt control block . (6) acknowledge block and its operation the acknowledge block operates only in the i 2 c bus mode. (7) shift clock generation timing in serial i/o mode (a) on releasing wait status from initial status the initial status is the status when the internal clock operation in the serial i/o mode has been selected. in the wait status, a high level is output to the shift clock pin.
238 m pd17704, 17705, 17707, 17708, 17709 figure 16-15. shift clock generation timing in serial i/o mode (1/4) wait period 1/f sc shift clock wait released initialization 1 : 1 (b) when wait operation is performed <1> if wait status is set under condition specified by sio0wrq0 and sio0wrq1 flags (normal operation) figure 16-15. shift clock generation timing in serial i/o mode (2/4) shift clock wait released status wait period 1/f sc wait released wait by sio0wrq1 and sio0wrq0 <2> if forced wait is set in wait status figure 16-15. shift clock generation timing in serial i/o mode (3/4) shift clock wait period wait period forced wait set by sio0nwt
239 m pd17704, 17705, 17707, 17708, 17709 <3> if forced wait is set after wait status has been released figure 16-15. shift clock generation timing in serial i/o mode (4/4) wait period wait released status 1/f sc forced wait by sio0nwt ab wait released wait period wait released status a + b = 1/2f sc a + b = 1/2f sc 1/f sc forced wait by sio0nwt ab wait released <4> if wait status is released when it has been already released once the clock output waveform is not affected. however, note that the clock counter is reset. (8) operations of sbstt and sbbsy flags the sbstt and sbbsy flags operate only in the i 2 c bus mode. these flags remain 0 in the serial i/o mode.
240 m pd17704, 17705, 17707, 17708, 17709 16.2.10 cautions on setting and reading data data is set to the presettable shift register 0 by using the put sio0sfr, dbf instruction. to read the data of this register, the get dbf, sio0sfr instruction is used. set or read data of the register in the wait status. if the wait status is released, data may not be correctly set or read depending on the status of the shift clock pin. the following table shows the data setting and reading timing, and points to be noted. table 16-3. reading and writing data of presettable shift register 0 and cautions status on execution status of shift i 2 c bus mode serial i/o mode of put/get clock pin wait read (get) ? i 2 c bus mode: normal read normal read status write (put) fixed to low normal write normal write ? serial i/o mode: outputs contents of msb when wait outputs contents of msb when wait fixed to high status is released next time status is released next time and shift (during transmission) clock pin goes low (during transmission) wait read (get) high level cannot be read normally cannot be read normally released contents of sio0sfr are lost contents of sio0sfr are lost status low level normal read normal read write (put) high level normal write normal write outputs contents of msb at falling outputs contents of msb when put of clock next to one at which put instruction is executed. instruction has been executed. clock counter is not reset clock counter is not reset low level cannot be read normally cannot be read normally contents of sio0sfr are lost contents of sio0sfr are lost msb data wait released put sio0sfr, dbf clock h l 1 0 msb data wait released put sio0sfr, dbf clock h l 1 0 msb data clock h l 1 0 put sio0sfr, dbf msb data put sio0sfr, dbf clock h l 1 0
241 m pd17704, 17705, 17707, 17708, 17709 16.2.11 operation of serial interface 0 tables 16-4 through 16-6 outlines the operations in each communication mode. table 16-4. outline of operation in i 2 c bus mode operation mode i 2 c bus mode slave operation (sio0ms = 0) master operation (sio0ms = 1) reception transmission reception transmission item (sio0tx = 0) (sio0tx = 1) (sio0tx = 0) (sio0tx = 1) status of sda/p0a3 when p0abio3 = 0 outputs contents of when p0abio3 = 0 outputs contents of each pin floating sio0sfr at falling of floating sio0sfr at falling of waits for input of external clock waits for input of internal clock external data regardless of external data regardless of p0abio3 when p0abio3 = 1 p0abio3 when p0abio3 = 1 general-purpose general-purpose output port output port outputs content of outputs content of output latch output latch scl/p0a2 when p0abio2 = 0 outputs internal clock regardless of p0abio2 floating waits for input of external data when p0abio2 = 1 general-purpose output port outputs content of output latch clock counter incremented at rising of scl pin operation of output not output shifted from msb not output shifted from msb presettable each time scl falls each time scl falls shift register 0 and is output and is output input shifted from lsb each time scl rise and is input wait operation in wait scl and sda pins scl pin is floated scl pin outputs low scl pin outputs low status are floated and sda pin retains level and sda pin is level and sda pin its status floated retains its status wait scl pin is floated scl pin is floated scl pin outputs scl pin outputs released and waits for input of and waits for input of internal clock. internal clock. external clock. external clock. sda pin is floated sda pin outputs data sda pin is floated and sda pin outputs data and waits for external each time scl pin falls waits for external data each time scl pin falls data acknowledge ack output at falling ack input at rising ack output at falling ack input at rising of 8th clock of 9th clock of 8th clock of 9th clock CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
242 m pd17704, 17705, 17707, 17708, 17709 table 16-5. outline of operation in 2-wire serial i/o mode operation mode 2-wire serial i/o mode slave operation (sio0ms = 0) master operation (sio0ms = 1) reception transmission reception transmission item (sio0tx = 0) (sio0tx = 1) (sio0tx = 0) (sio0tx = 1) status of sda/p0a3 when p0abio3 = 0 outputs contents of when p0abio3 = 0 outputs contents of each pin floating sio0sfr at falling of floating sio0sfr at falling of waits for input of external clock waits for input of internal clock external data regardless of p0abio3 external data regardless of p0abio3 when p0abio3 = 1 when p0abio3 = 1 general-purpose general-purpose output port output port outputs contents outputs contents of of output latch output latch scl/p0a2 when p0abio2 = 0 outputs internal clock regardless of p0abio2 floating waits for input of external data when p0abio2 = 1 general-purpose output port outputs contents of output latch clock counter incremented at rising of scl pin operation of output not output shifted from msb not output shifted from msb presettable each time scl falls each time scl falls shift register 0 and is output and is output input shifted from lsb each time scl rise and is input wait operation in wait scl and sda pins scl pin is floated scl pin outputs high scl pin outputs high status are floated and sda pin retains level and sda pin is level and sda pin its status floated retains its status wait scl pin is floated scl pin is floated scl pin outputs scl pin outputs released and waits for input of and waits for input internal clock. internal clock. external clock. of external clock. sda pin is floated and sda pin outputs data sda pin is floated and sda pin outputs data waits for external data each time scl pin falls waits for external data each time scl pin falls CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
243 m pd17704, 17705, 17707, 17708, 17709 table 16-6. outline of operation in 3-wire serial i/o mode operation mode 3-wire serial i/o mode slave operation (sio0ms = 0) master operation (sio0ms = 1) reception transmission reception transmission item (sio0tx = 0) (sio0tx = 1) (sio0tx = 0) (sio0tx = 1) status of sck0/p0a1 when p0abio1 = 0 outputs internal clock regardless of p0abio1 each pin floating waits for input of external data when p0abio1 = 1 general-purpose output port outputs contents of output latch so0/p0a0 when p0abio0 = 0 outputs contents of when p0abio0 = 0 outputs contents of general-purpose sio0sfr at falling general-purpose sio0sfr at falling input port edge of external clock input port edge of internal floating regardless of floating clock regardless of when p0abio0 = 1 p0abio0 when p0abio0 = 1 p0abio0 general-purpose general-purpose output port output port outputs contents outputs contents of output latch of output latch si0/p0b3 when p0bbio3 = 0 floating waits for input of external data when p0bbio3 = 1 general-purpose output port outputs contents of output latch clock counter incremented at rising of sck0 pin operation of output not output shifted from msb not output shifted from msb presettable each time sck0 falls each time sck0 falls shift register 0 and is output and is output input shifted from lsb each time sck0 falls and is input wait operation in wait sck0 pin is floated. sck0 pin is floated. sck0 pin outputs high sck0 pin outputs high status so0 pin as general- sc0 pin retains its level level. purpose port. status. so0 pin as general- so0 pin retains its si0 pin is floated si0 pin is floated purpose port. status. si0 pin is floated si0 pin is floated wait sck0 pin is floated sck0 pin is floated sck0 pin is floated sck0 pin is floated released and waits for input of and waits for input of and waits for input of and waits for input of external clock. external clock. external clock. external clock. so0 pin as general- so0 pin outputs data. so0 pin as general- so0 pin outputs data. purpose port. si0 pin is floated and purpose port. si0 pin is floated and si0 pin is floated and waits for input of si0 pin is floated and waits for input of waits for input of external data waits for input of external data external data external data CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
244 m pd17704, 17705, 17707, 17708, 17709 16.2.12 status of serial interface 0 at reset (1) at power-on reset each pin is set in the general-purpose input port mode. the contents of presettable shift register 0 are undefined. (2) at wdt&sp reset each pin is set in the general-purpose input port mode. the contents of presettable shift register 0 are undefined. (3) on execution of clock stop instruction each pin is set in the general-purpose i/o port mode and remains in the previous input or output mode. the contents of presettable shift register 0 are undefined. (4) at ce reset each pin is set in the general-purpose i/o port mode and remains in the previous input or output mode. the contents of presettable shift register 0 are undefined. (5) in halt status each pin retains its set status. output of the internal clock is stopped in the status where the halt instruction is executed. when an external clock is used, the operation continues even if the halt instruction is executed. presettable shift register 0 retains the previous value.
245 m pd17704, 17705, 17707, 17708, 17709 16.3 serial interface 1 16.3.1 outline of serial interface 1 figure 16-16 outlines the serial interface 1. serial interface 1 is used in the 3-wire serial i/o mode. figure 16-16. outline of serial interface 1 sck1/p0b2 sio1ck0 and 1 flags sio1hiz flag clock i/o control block data i/o control block wait signal sio1ts flag 4.5 mhz wait control block clock control block clock counter count value: 8 irqsio1 flag presettable shift register 1 (sio1sfr) so1/p0b1 si1/p0b0 out in remarks 1. sio1ck1 and sio1ck0 (bits 1 and 0 of serial i/o1 mode selection register: refer to figure 16-17 ) select a shift clock. 2. sio1ts (bit 3 of serial i/o1 mode selection register: refer to figure 16-17 ) starts or stops communication operation. 3. sio1hiz (bit 2 of serial i/o1 mode selection register: refer to figure 16-17 ) selects the function of the so1/p0b1 pin. 16.3.2 clock i/o control block and data i/o control block the clock i/o control block and data i/o control block control the transmission or reception operation of serial interface 1 and selects a shift clock. the internal clock (master) or external clock (slave) operation is selected by the sio1ck0 and 1 flags. the sio1hiz flag selects whether the so1 pin is used as a serial data output pin. the flags that control the clock i/o control block and data i/o control block are allocated to the serial i/o1 mode selection register. figure 16-17 shows the configuration and function of the serial i/o1 mode selection register. table 16-7 shows the set status of each pin. as shown in this table, flags that set the input or output mode of each pin must also be manipulated in addition to the control flags of the serial interface, in order to set each pin .
246 m pd17704, 17705, 17707, 17708, 17709 figure 16-17. configuration of serial i/o1 mode selection register 16.3.3 clock counter the clock counter is a wrap-around counter that counts the rising edges of the clock. because this counter directly reads the status of the clock pin, whether the clock is an internal clock or external clock cannot be identified. the contents of the clock counter cannot be directly read by software. name flag symbol b 3 s i o 1 t s b 2 s i o 1 h i z b 1 s i o 1 c k 1 b 0 s i o 1 c k 0 address 1dh read/write r/w serial i/o1 mode selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 0 0 0 external clock input 187.50 khz 375.00 khz 46.875 khz selects shift clock of serial interface 1 0 0 0 0 0 0 0 0 0 0 1 1 general-purpose i/o port serail data output pin selects function of p0b1/so1 pin 0 1 0 0 0 0 stops (wait status) starts start or stops operation of serial communication 0 1
247 m pd17704, 17705, 17707, 17708, 17709 table 16-7. status of each pin set by control flag each flag pin communication mode setting of sio1 pin clock setting pin name set status of pin s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0 p 0 b b i o 2 p 0 b b i o 1 p 0 b b i o 0 3-wire serial i/o external clock sck1/p0b2 00 0 wait: general-purpose input port internal clock 01 1 wait: general-purpose output port wait released: external clock input wait released: general-purpose output port 10 0 general-purpose input port 11 1 wait: high-level output wait released: internal clock output general- purpose port serial output 0 1 so1/p0b1 si1/p0b0 0 1 0 1 general-purpose input port general-purpose output port general-purpose input port serial data output serial data intput general-purpose output port 0 1
248 m pd17704, 17705, 17707, 17708, 17709 16.3.4 presettable shift register 1 presettable shift register 1 is an 8-bit shift register that writes serial out data and reads serial in data. this register writes or reads data via data buffer. it outputs the contents of the most significant bit (msb) from the serial data i/o pin in synchronization with the falling edge of the shift clock (during transmission operation), and reads data to the least significant bit (lsb) in synchronization with the rising edge of the serial clock. figure 16-18 shows the configuration of the presettable shift register 1. figure 16-18. configuration of presettable shift register 1 note data may be destroyed if the put or get instruction is executed during serial communication. for details, refer to 16.3.7 cautions on setting and reading data . 16.3.5 wait control block the wait control block keeps communication waiting or releases communication from the wait status. serial communication is started when communication is released from the wait status by using the sio1ts flag of the serial i/o1 mode selection register. communication is set in the wait status eight clocks after the wait status has been released and communication has been started. the communication status can be detected by using the sio1ts flag. to do so, detect the status of the sio1ts flag after setting this flag to 1. if 0 is written to the sio1ts flag when communication is released from the wait status, the wait status is set. this wait status is called forced wait status. for the configuration of the serial i/o1 mode selection register, refer to figure 16-17 . data buffer dbf3 don't care dbf2 don't care name presettable shift register 1 symbol sio1sfr peripheral register 04h dbf1 dbf0 b 3 b 2 b 1 b 0 l s b b 7 m s b b 6 b 5 b 4 peripheral register d3 d2 d1 d0 d7 d6 d5 d4 d7 d6 d5 d4 d3 d2 d1 d0 serial out serial in transfer data valid data sets serial out data and reads serial in data get note put note 8
249 m pd17704, 17705, 17707, 17708, 17709 16.3.6 operation of serial interface 1 (1) timing chart figure 16-19 shows the timing chart. figure 16-19. timing chart of serial interface 1 shift clock serial data la d7 12 1 0 <1> <2> <3> int <5> <4> 267801 378 1 d6 d5 d1 d0 d7 clock counter sio1ts <1> initial status (general-purpose input port) <2> sets transmission status of master/releases wait status <3> wait timing <4> releases wait status again <5> interrupt issuance timing (2) operation of clock counter the value of the clock counter is incremented from the initial value 0 each time the rising of the clock pin has been detected. the value of the clock counter returns to 0 after it has reached 8, and the clock counter continues counting. the clock counter is also reset in the following cases. ? at reset (power-on reset, wdt&sp reset, ce reset) ? on execution of clock stop instruction ? if 0 is written to sio1ts flag (3) wait operation and cautions when the wait status is released, serial data is output (during transmission operation) at the falling of the next clock, and the wait status is released at the eighth clock. after eight clocks have been output, the shift clock pin is made high, and the operations of the clock counter and presettable shift register 1 are stopped. the value of the presettable shift register 1 cannot be read correctly if it is read while the wait status is released and while the shift clock pin is high. correct data cannot be written to the presettable shift register 1 while the wait status is released and while the shift clock pin is low. if the forced wait status is specified while the wait status is released, the forced wait status is set as soon as 0 has been written to the sio1ts flag, and the clock counter is reset.
250 m pd17704, 17705, 17707, 17708, 17709 (4) interrupt request issuance timing an interrupt request is issued at the rising of the shift clock when the value of the clock counter is 8. (5) shift clock generation timing (a) on releasing wait status from initial status the initial status is the status when the p0b2/sck1 pin is set in the output mode and the internal clock operation is selected. in the wait status, a high level is output to the shift clock pin. the wait status can be released and a clock can be selected at the same time. figure 16-20. shift clock generation timing of serial interface 1 (1/4) 1/f sc wait status shift clock wait released initialization 1 : 1 (b) when wait operation is performed (normal operation) <1> if wait status is set at the 8th clock (normal operation) figure 16-20. shift clock generation timing of serial interface 1 (2/4) shift clock wait wait release period wait period 1/f sc wait released
251 m pd17704, 17705, 17707, 17708, 17709 <2> if forced wait is set in wait status figure 16-20. shift clock generation timing of serial interface 1 (3/4) <4> if wait status is released when it has been already released the clock output waveform is not affected. the clock counter is not reset. shif clock wait period wait period forced wait set by sio1ts <3> if forced wait is set after wait status has been released note that the clock counter is reset. figure 16-20. shift clock generation timing of serial interface 1 (4/4) a b wait status wait released status 1/f sc shift clock shift clock forced wait by sio1ts wait released a b wait status wait released status 1/f sc a + b = 1/2f sc a + b = 1/2f sc forced wait by sio1ts wait released
252 m pd17704, 17705, 17707, 17708, 17709 16.3.7 cautions on setting and reading data data is set to the presettable shift register 1 by using the put sio1sfr, dbf instruction. to read the data of this register, the get dbf, sio1sfr instruction is used. set or read data of the register in the wait status. if the wait status is released, data may not be correctly set or read depending on the status of the shift clock pin. the following table shows the data setting and reading timing, and points to be noted. table 16-8. reading and writing data of presettable shift register and cautions status on execution status of shift serial i/o mode of put/get clock pin wait read (get) ? external clock: normal write status write (put) floating normal write ? internal clock: outputs contents of msb when wait status is released next time and shift clock output latch pin falls (during transmission) (always high) wait read (get) high level cannot be read normally released contents of sio1sfr are lost status low level normal write write (put) high level normal write outputs contents of msb at which put instruction has been executed. clock counter is not reset low level cannot be read normally contents of sio1sfr are lost data msb wait released put sio1sfr, dbf clock h l 1 0 data msb put sio1sfr, dbf clock h l 1 0
253 m pd17704, 17705, 17707, 17708, 17709 16.3.8 operation mode and operation of each part tables 16-9 outlines the operations of the 3-wire serial i/o mode. table 16-9. outline of operation of serial interface 1 operation mode 3-wire serial i/o mode slave operation master operation item (sio1ck1 = sio1ck0 = 0) (sio1ck1 = sio1ck0 = other than 0) status of p0b2/sck1 during wait wait released during wait wait released each pin (sio1ts = 0) (sio1ts = 1) (sio1ts = 0) (sio1ts = 1) when p0bbio2 = 0 when p0bbio2 = 0 when p0bbio2 = 0 when p0bbio2 = 0 floating floating floating floating general-purpose waits for input of general-purpose general-purpose input port external clock input port input port when p0bbio2 = 1 when p0bbio2 = 1 when p0bbio2 = 1 when p0bbio2 = 1 general-purpose general-purpose general-purpose outputs internal clock output port output port output port outputs contents of outputs contents outputs high level output latch of output latch p0b1/so1 sio1hiz = 0 sio1hiz = 1 sio1hiz = 0 sio1hiz = 1 when p0bbio1 = 0 when p0bbio1 = 0 when p0bbio1 = 0 when p0bbio1 = 0 floating floating floating floating general-purpose general-purpose general-purpose general-purpose input port input port input port input port when p0bbio1 = 1 when p0bbio1 = 1 when p0bbio1 = 1 when p0bbio1 = 1 general-purpose outputs data general-purpose outputs data output port output port outputs contents of outputs contents of output latch output latch p0b0/si1 when p0bbio0 = 0 floating waits for input of serial data when p0bbio0 = 1 general-purpose output port outputs contents of output latch clock counter incremented at rising of sck1 pin operation of output sio1hiz = 0 presettable not output shift register 1 sio1hiz = 1 shifted from msb each time sck1 pin falls and is output input shifted from lsb each time sck1 pin rises and is input. si1 pin outputs contents of output latch when p0bbio0 = 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
254 m pd17704, 17705, 17707, 17708, 17709 16.3.9 status of serial interface 1 at reset (1) at power-on reset each pin is set in the general-purpose input port mode. the contents of presettable shift register 1 are undefined. (2) at wdt&sp reset each pin is set in the general-purpose input port mode. the contents of presettable shift register 1 are undefined. (3) on execution of clock stop instruction each pin is set in the general-purpose i/o port mode and remains in the previous input or output mode. the contents of presettable shift register 1 are undefined. (4) at ce reset each pin is set in the general-purpose i/o port mode and remains in the previous input or output mode. the contents of presettable shift register 1 are undefined. (5) in halt status each pin retains its set status. output of the internal clock is stopped in the status where the halt instruction is executed. when an external clock is used, the operation continues even if the halt instruction is executed. presettable shift register 1 retains the previous contents.
255 m pd17704, 17705, 17707, 17708, 17709 17. pll frequency synthesizer the pll (phase locked loop) frequency synthesizer is used to lock a frequency in the mf (medium frequency), hf (high frequency), and vhf (very high frequency) to a constant frequency by means of phase difference comparison. 17.1 outline of pll frequency synthesizer figure 17-1 outlines the pll frequency synthesizer. a pll frequency synthesizer can be configured by connecting an external lowpass filter (lpf) and voltage controlled oscillator (vco). the pll frequency synthesizer divides a signal input from the vcoh or vcol pin by using a programmable divider and outputs a phase difference between this signal and a reference frequency from the eo0 and eo1 pins. the pll frequency synthesizer operates only while the ce pin is high. it is disabled when the ce pin is low. for the details of the disabled status of the pll frequency synthesizer, refer to 17.5 pll disabled status . figure 17-1. outline of pll frequency synthesizer input select block programmable divider (pd) reference frequency generator 4.5 mhz pllscnf flag dbf pllrfck3 flag pllrfck2 flag pllrfck1 flag pllrfck0 flag pllul flag pllmd1 flag pllmd0 flag vcoh vcol eo1 eo0 phase comparator ( -det) charge pump lowpass filter (lpf) voltage controlled oscillator (vco) unlock ff note note f note external circuit remarks 1. pllmd1 and pllmd0 (bits 1 and 0 of pll mode selection register: refer to figure 17-3 ) selects a division mode of the pll frequency synthesizer. 2. pllscnf (bit 3 of pll mode selection register: refer to figure 17-3 ) selects the least significant bit of the swallow counter. 3. pllrfck3 through pllrfck0 (bits 3 through 0 of pll reference frequency selection register: refer to figure 17-6 ) selects a reference frequency fr of the pll frequency synthesizer. 4. pllul (bit 0 of pll unlock ff register: refer to figure 17-9 ) detects the pll unlock ff status.
256 m pd17704, 17705, 17707, 17708, 17709 17.2 input selection block and programmable divider 17.2.1 configuration and function of input selection block and programmable divider figure 17-2 shows the configuration of the input selection block and programmable divider. the input selection block selects an input pin and division mode of the pll frequency synthesizer. the vcoh or vcol pin can be selected as the input pin. the voltage on the selected pin is at the intermediate level (approx. 1/2 v dd ). the pin not selected is internally pulled down. because these pins are connected to an internal ac amplifier, cut the dc component of the input signal by connecting a capacitor in series to the pin. direct division mode and pulse swallow mode can be selected as division modes. the programmable divider divides the frequency of the input signal according to the value set to the swallow counter and programmable counter. the pin and division mode to be used are selected by the pll mode selection register. figure 17-3 shows the configuration of the pll mode selection register. the value of the programmable divider is set by using the pll data register via data buffer. figure 17-2. configuration of input selection block and programmable divider note pllscnf flag pllmd1 flag pllmd0 flag vcoh vcol pll disable signal 2- modulus prescaler 1/32, 1/33 programmable counter 12 bits f n -det swallow counter 5 bits 4 16 12 dbf pll data register 12 bits 4 bits r f note f to
257 m pd17704, 17705, 17707, 17708, 17709 figure 17-3. configuration of pll mode selection register 17.2.2 outline of each division mode (1) direct division mode (mf) in this mode, the vcol pin is used. the vcoh pin is pulled down. in this mode, only the programmable counter is used for frequency division. (2) pulse swallow mode (hf) in this mode, the vcol pin is used. the vcoh pin is pulled down. in this mode, the swallow counter and programmable counter are used for frequency division. name flag symbol b 3 p l l s c n f b 2 0 b 1 p l l m d 1 b 0 p l l m d 0 address 10h read/write r/w pll mode selection power-on reset wdt&sp reset ce reset 1 clock stop at reset 0 1 0 1 0 0 0 0 disables vcol and vcoh pins direct division (vcol pin, mf mode) pulse swallow (vcoh pin, vhf mode) pulse swallow (vcol pin, hf mode) selects division mode of pll frequency synthesizer u u r r u: undefined r: retained 0 0 0 1 1 fixed to 0 0 0 0 0 clears least significant bit to 0 sets least significant bit to 1 selects least significant bit of swallow counter 0 1
258 m pd17704, 17705, 17707, 17708, 17709 (3) pulse swallow mode (vhf) in this mode, the vcoh pin is used. the vcol pin is pulled down. in this mode, the swallow counter and programmable counter are used for frequency division. (4) vcol and vcoh pin disabled in this mode, only the vcol and vcoh pins are internally pulled down, but the other blocks operate. 17.2.3 programmable divider and pll data register the programmable divider consists of a 5-bit swallow counter and a 12-bit programmable counter. each counter is a 17-bit binary down counter. the programmable counter is allocated to the high-order 12 bits of the pll data register, and the swallow counter is allocated to the low-order 4 bits. data are set to these counters via data buffer. the least significant bit of the swallow counter sets data to the pllscnf flag of the control register. the value by which the input signal frequency is to be divided is called n value. for how to set a division value (n value) in each division mode, refer to 17.6 using pll frequency synthesizer . (1) pll data register and data buffer figure 17-4 shows the relationships between the pll data register and data buffer. in the direct division mode, the high-order 12 bits of the pll data register are valid, and all 17 bits of the register are valid in the pulse swallow mode. in the direct division mode, all 12 bits are used as a programmable counter. in the pulse swallow mode, the high-order 12 bits are used as a programmable counter, and the low-order 5 bits are used as a swallow counter. (2) relationship between division value n of programmable divider and divided output frequency the relationship between the value n set to the pll data register and the signal frequency f n divided and output by the programmable divider is as shown below. for details, refer to 17.6 using pll frequency synthesizer . (a) direct division mode (mf) f in = f in n: 12 bits n (b) pulse swallow mode (hf, vhf) f in = f in n: 17 bits n
259 m pd17704, 17705, 17707, 17708, 17709 figure 17-4. setting division value (n value) of pll frequency synthesizer note the value of pllscnf flag is transferred when a write (put) instruction is executed to the pll data register (pllr). therefore, data must be set to the pllscnf flag before executing the write instruction to the pll data register. data buffer dbf3 dbf2 name pll data register symbol pllr peripheral address 42h dbf1 dbf0 b 3 b 2 b 1 b 0 b 3 b 0 b 0 b 1 b 1 b 2 b 2 b 3 b 3 b 4 b 4 b 5 b 5 b 6 b 6 b 7 b 7 b 8 b 8 b 9 b 9 b 10 b 10 b 11 b 11 b 12 b 12 b 13 b 13 b 14 b 14 b 15 b 15 b 16 b 6 b 5 b 4 b 10 b 9 b 8 b 7 b 13 b 12 b 15 b 14 b 11 peripheral register pll n value data (17 bits) direct division mode 0 don't care setting prohibited division value n: n = x setting prohibited division value n: n = x don't care don't care don't care 15 (00fh) 2 12 C1 (fffh) pulse swallow mode transfer data valid data sets high-order 16 bits of division value sets least significant bit of division value note name pll mode selection address 10h b 3 p l l s c n f p l l m d 1 p l l m d 0 0 b 2 b 1 b 0 register file get put 16 sets division value (n value) of pll frequency synthesizer x 0 1023 (3ffh) 2 17 ? (1ffffh) x don't care 16 (010h) 1024 (400h)
260 m pd17704, 17705, 17707, 17708, 17709 17.3 reference frequency generator figure 17-5 shows the configuration of the reference frequency generator. the reference frequency generator generates the reference frequency fr of the pll frequency synthesizer by dividing the 4.5 mhz output of a crystal oscillator. thirteen frequencies can be selected as reference frequency fr: 1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 18, 20, 25, and 50 khz. the reference frequency fr is selected by the pll reference frequency selection register. figure 17-6 shows the configuration and function of the pll reference frequency selection registerion. figure 17-5. configuration of reference frequency generator pllrfck3 flag pllrfck2 flag pllrfck1 flag pllrfck0 flag mux 1 khz 1.25 khz 2.5 khz 25 khz 50 khz off pll disable signal to -det divider 4.5 mhz f
261 m pd17704, 17705, 17707, 17708, 17709 figure 17-6. configuration of pll reference frequency selection register remark when the pll frequency synthesizer is disabled by the pll reference frequency selection register, the vcoh and vcol pins are internally pulled down. the eo1 and eo0 pins are floated. name flag symbol b 3 p l l r f c k 3 b 2 p l l r f c k 2 b 1 p l l r f c k 1 b 0 p l l r f c k 0 address 11h read/write r/w pll reference frequency selection power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1.25 khz 2.5 khz 5 khz 10 khz 6.25 khz 12.5 khz 25 khz 50 khz 3 khz 9 khz 18 khz setting prohibited 1 khz 20 khz setting prohibited pll disable sets reference frequency f r of pll frequency synthesizer 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 1
262 m pd17704, 17705, 17707, 17708, 17709 17.4 phase comparator ( f -det), charge pump, and unlock ff 17.4.1 configuration of phase comparator, charge pump, and unlock ff figure 17-7 shows the configuration of the phase comparator, charge pump, and unlock ff. the phase comparator compares the phase of the divided frequency f n output by the programmable divider with the phase of the reference frequency fr output by the reference frequency generator, and outputs an up (up) or down (dw) request signal. the charge pump outputs the output of the phase comparator from an error out pin (eo1 and eo0 pins). the unlock ff detects the unlock status of the pll frequency synthesizer. 17.4.2 through 17.4.4 describe the operations of the phase comparator, charge pump, and unlock ff. figure 17-7. configuration of phase comparator, charge pump, and unlock ff unlock ff pllul flag up f r f n charge pump eo1 eo0 reference frequency generator programmable divider dw pll disable signal phase comparator ( - det) f
263 m pd17704, 17705, 17707, 17708, 17709 17.4.2 function of phase comparator as shown in figure 17-7, the phase comparator compares the phases of the divided frequency f n output by the programmable divider and the reference frequency fr, and outputs an up or down request signal. if the divided frequency f n is lower than reference frequency fr, the up request signal is output. if f n is higher than fr, the down request signal is output. figure 17-8 shows the relationship between reference frequency fr, divided frequency f n , up request signal, and down request signal. when the pll frequency synthesizer is disabled, neither the up request nor the down request signal is output. the up and down request signals are input to the charge pump and unlock ff, respectively. figure 17-8. relationship between fr, f n , up, and dw (a) if f n lags behind fr (b) if f n leads fr (c) if f n and fr are in phase (d) if f n is lower than fr f r f n up dw f r f n up dw f r f n up dw f r f n up dw
264 m pd17704, 17705, 17707, 17708, 17709 17.4.3 charge pump as shown in figure 17-7, the charge pump outputs the up request and down request signals output by the phase comparator, from the error out pins (eo1 and eo0 pins). therefore, the relationship between the output of the error out pins, divided frequency f n and reference frequency fr is as follows: where reference frequency fr > divided frequency f n : low-level output where reference frequency fr < divided frequency f n : high-level output where reference frequency fr = divided frequency f n : floating 17.4.4 unlock ff as shown in figure 17-7, the unlock ff detects the unlock status of the pll frequency synthesizer from the up request and down request signals of the phase comparator. because either the up request or down request signal is low in the unlock status, the unlock status is detected by this low-level signal. in the unlock status, the unlock ff is set to 1. the unlock ff is set in the cycle of the reference frequency fr selected at that time. when the contents of the pll unlock ff register are read (by the peek instruction), the unlock ff is reset (read & reset). therefore, the unlock ff must be detected in a cycle longer than cycle 1/fr of the reference frequency fr. the status of the unlock ff is detected by the pll unlock ff register. figure 17-9 shows the configuration of the pll unlock ff register. because this register is a read-only register, its contents can be read to the window register by the peek instruction. because the unlock ff is set in a cycle of the reference frequency fr, the contents of the pll unlock ff register are read to the window register in a cycle longer than cycle 1/fr of the reference frequency. the delay time of the up and down request signals of the phase comparator are fixed to 0.8 to 1.0 m s.
265 m pd17704, 17705, 17707, 17708, 17709 figure 17-9. configuration of pll unlock ff register name flag symbol b 3 0 b 2 0 b 1 0 b 0 p l l u l address 12h read/write r & reset pll unlock ff power-on reset wdt&sp reset ce reset u: undefined r: retained clock stop at reset 0 1 u u r r unlock ff = 0: pll locked status unlock ff = 1: pll unlocked status fixed to 0 detects status of unlock ff 000
266 m pd17704, 17705, 17707, 17708, 17709 17.5 pll disabled status the pll frequency synthesizer stops (is disabled) while the ce pin is low. likewise, it also stops when pll disabled status is selected by the pll reference frequency register (rf address 11h). table 17-1 shows the operation of each block in the pll disabled status. when the vcol and vcoh pins are disabled by the pll mode selection register, only the vcol and vcoh pins are internally pulled down, and the other blocks operate. because the pll frequency selection register and pll mode selection register are not initialized at ce reset (hold the previous status), these registers return to the previous status when the ce pin has gone low, the pll frequency synthesizer has been disabled, and then ce pin has gone high. to disable the pll frequency synthesizer at ce reset, initialize these registers in software. at power-on reset, the pll frequency synthesizer is disabled. table 17-1. operation of each block under each pll disable condition condition ce pin = low level ce pin = high level (pll disabled) pll reference frequency pll mode selection selection register = 1111b register = 0000b each block (pll disabled) (vcoh and vcol disabled) vcol, vcoh pins internally pulled down internally pulled down internally pulled down programmable divider division stopped division stopped operates reference frequency generator output stopped output stopped operates phase comparator output stopped output stopped operates charge pump error out pins are floated error out pins are floated operates. however, usually outputs low level because no signal is input
267 m pd17704, 17705, 17707, 17708, 17709 17.6 using pll frequency synthesizer to control the pll frequency synthesizer, the following data is necessary. (1) division mode : direct division (mf), pulse swallow (hf, vhf) (2) pins used : vcol and vcoh pins (3) reference frequency : fr (4) division value : n 17.6.1 through 17.6.3 below describe how to set pll data in each division mode (mf, hf, and vhf). 17.6.1 direct division mode (mf) (1) selecting division mode select the direct division mode by using the pll mode selection register. (2) pins used the vcol pin is enabled to operate when the direct division mode is selected. (3) selecting reference frequency fr select the reference frequency by using the pll reference frequency selection register. (4) calculation of division value n calculate n as follows: n = f vcol fr f vcol : input frequency of vcol pin fr : reference frequency (5) example of setting pll data how to set data to receive broadcasting in the following mw band is described below. reception frequency : 1422 khz (mw band) reference frequency : 9 khz intermediate frequency : +450 khz division value n is calculated as follows: n = f vcol = 1422 + 450 = 208 (decimal) fr 9 = 0d0h (hexadecimal) set data to the pll data register, pll mode selection register, and pll reference frequency selection register as follows:
268 m pd17704, 17705, 17707, 17708, 17709 notes 1. pllscnf flag 2. dont care pll data register (pllr) 0 0 0 0 0 0 0 0 0 0 don't care 1 1 0 1 d pll mode selection register pll reference frequency selection register note 1 note 2 1 1 0 1 9 khz 0 0 1 mf
269 m pd17704, 17705, 17707, 17708, 17709 17.6.2 pulse swallow mode (hf) (1) selecting division mode select the pulse swallow mode by using the pll mode selection register. (2) pins used the vcol pin is enabled to operate when the pulse swallow mode is selected. (3) selecting reference frequency fr select the reference frequency by using the pll reference frequency selection register. (4) calculation of division value n calculate n as follows: n = f vcol fr f vcol : input frequency of vcol pin fr : reference frequency (5) example of setting pll data how to set data to receive broadcasting in the following sw band is described below. reception frequency : 25.50 mhz (sw band) reference frequency : 5 khz intermediate frequency : +450 khz division value n is calculated as follows: n = f vcol = 25500 + 450 = 5190 (decimal) fr 5 = 1446h (hexadecimal) set data to the pll data register, pll mode selection register, and pll reference frequency selection register as follows: caution the division value n is 17 bits long when the pulse swallow mode is selected, and the least significant bit of the swallow counter is the bit 3 of the pll mode selection register (pllscnf). to set 1446h as the division value n, the value to be actually set to the pll data register is 0a23h. note pllscnf flag pll data register (pllr) 0 0 0 0 0 0 1 00 0 1 1 1 0 1 0 pll mode selection register pll reference frequency selection register note 0 0 0 1 0 0 1 1 5 khz hf 6 4 4 1
270 m pd17704, 17705, 17707, 17708, 17709 17.6.3 pulse swallow mode (vhf) (1) selecting division mode select the pulse swallow mode by using the pll mode selection register. (2) pins used the vcoh pin is enabled to operate when the pulse swallow mode is selected. (3) selecting reference frequency fr select the reference frequency by using the pll reference frequency selection register. (4) calculation of division value n calculate n as follows: n = f vcoh fr f vcoh : input frequency of vcoh pin fr : reference frequency (5) example of setting pll data how to set data to receive broadcasting in the following fm band is described below. reception frequency : 98.15 mhz (fm band) reference frequency : 50 khz intermediate frequency : +10.7 mhz division value n is calculated as follows: n = f vcoh = 98.15 + 10.7 = 2177 (decimal) fr 0.050 = 0881h (hexadecimal) set data to the pll data register, pll mode selection register, and pll reference frequency selection register as follows: caution the division value n is 17 bits long when the pulse swallow mode is selected, and the least significant bit of the swallow counter is the bit 3 of the pll mode selection register (pllscnf). to set 0881h as the division value n, the value to be actually set to the pll data register is 0440h. pll data register (pllr) 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 pll mode selection register pll reference frequency selection register note 1 0 1 0 50 khz vhf 1 8 8 0 0 1 1 1 note pllscnf flag
271 m pd17704, 17705, 17707, 17708, 17709 note that data must be set to the pllscnf flag before a write (put) instruction is executed to the pll data register (pllr). example set1 pllscnf mov dbf0, #0 mov dbf1, #4 mov dbf2, #4 put pllr, dbf 17.7 status at reset 17.7.1 at power-on reset the pll frequency synthesizer is disabled because the pll reference frequency selection register is initialized to 1111b. 17.7.2 at wdt&sp reset the pll frequency synthesizer is disabled because the pll reference frequency selection register is initialized to 1111b. 17.7.3 on execution of clock stop instruction the pll frequency synthesizer is disabled because the pll reference frequency selection register is initialized to 1111b. 17.7.4 at ce reset the pll frequency synthesizer is disabled because the pll reference frequency selection register is initialized to 1111b. 17.7.5 in halt status the set status is retained if the ce pin is high.
272 m pd17704, 17705, 17707, 17708, 17709 18. frequency counter 18.1 outline of frequency counter figure 18-1 outlines the frequency counter. the frequency counter has an if counter function to count the intermediate frequency (if) of an external input signal and an external gate counter (fcg: frequency counter for external gate signal) to detect the pulse width of an external input signal. the if counter function counts the frequency input to the p1c0/fmifc or p1c1/amifc pin at fixed intervals (1 ms, 4 ms, 8 ms, or open) by using a 16-bit counter. the external gate counter function counts the frequency of the internal clock (1 khz, 100 khz, 900 khz) from the rising to the falling of the signal input to the p2a1/fcg1 or p2a0/fcg0 pin. the if counter and external gate counter functions cannot be used at the same time. figure 18-1. outline of frequency counter i/o selection block gate time control block start/stop control block if counter (16 bits) p2a1/fcg1 fcgch1 flag fcgch0 flag ifcck1 flag ifcck0 falg ifcstrt flag dbf ifcgostt flag ifcres flag ifcmd1 flag ifcmd0 fla g p2a0/fcg0 p1c0/fmifc p1c1/amifc remarks 1. fcgch1 and fcgch0 (bits 1 and 0 of fcg channel selection register: refer to figure 18-4 ) select the pin used for the external gate counter function. 2. ifcmd1 and ifcmd0 (bits 3 and 2 of if counter mode selection register: refer to figure 18-3 ) select the if counter or external gate counter function. 3. ifcck1 and ifcck0 (bits 1 and 0 of if counter mode selection register: refer to figure 18-3 ) select the gate time of the if counter function and the reference frequency of the external gate counter function. 4. ifcstrt (bit 1 of if counter control register: refer to figure 18-6 ) control starting of the if counter and external gate counter functions. 5. ifcgostt (bit 0 of if counter gate status detection register: refer to figure 18-7 ) detects opening/ closing the gate of the if counter function. 6. ifcres (bit 0 of if counter control register: refer to figure 18-6 ) reset the count value of the if counter.
273 m pd17704, 17705, 17707, 17708, 17709 18.2 input/output selection block and gate time control block figure 18-2 shows the configuration of the input/output selection block and gate time control block. the input/output selection block consists of an if counter input selection block and fcg i/o selection block. the if counter input selection block selects whether the frequency counter is used as an if counter or an external gate counter, by using the if counter mode register. when the frequency counter is used as the if counter, either p1c0/fmifc or p1c1/amifc pin and a count mode are selected. the pin not used for the if counter is used as a general-purpose input port pin. the fcg i/o selection block selects the p2a1/fcg1 or p2a0/fcg0 pin by using the fcg channel selection register, when the frequency counter is used as the external gate counter. the pin not used is used as a general- purpose i/o port pin. when using the frequency counter as the external gate counter, the pin to be used must be set in the input mode by using the port 2a bit i/o selection register. this is because the pin is set in the general-purpose output port mode if it is set in the output mode even if the external gate counter function is selected by the if counter mode selection register and fcg channel selection register. the gate time control block selects gate time by using the if counter mode selection register when the frequency counter is used as the if counter, or a count frequency when the frequency counter is used as the external gate counter. figure 18-3 shows the configuration of the if counter mode selection register. figure 18-4 shows the configuration of the fcg channel selection register. figure 18-2. configuration of i/o selection block and gate time control block 1/2 p2a1/fcg1 p2a0/fcg0 p1c0/fmifc p1c1/amifc input port fmifc amifc gate signal generator frequency generator selector frequency gate signal to start/stop control block i/o port fcgch1 flag fcgch0 flag ifcmd1 flag ifcmd0 flag fcg ifcck1 flag ifcck0 flag selector
274 m pd17704, 17705, 17707, 17708, 17709 figure 18-3. configuration of if counter mode selection register caution the if counter and external gate counter functions cannot be used at the same time. name flag symbol b 3 i f c m d 1 b 2 i f c m d 0 b 1 i f c c k 1 b 0 i f c c k 0 address 22h read/write r/w if counter mode selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 0 0 0 1 ms 4 ms 8 ms open 1 khz 100 khz 900 khz setting prohibited selects gate time of if counter and reference frequency of external gate counter gate time of if counter reference frequency of external gate counter 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 1 external gate counter (fcg) if counter (amifc pin, amif count mode) if counter (fmifc pin, fmif count mode, 1/2 division) if counter (fmifc pin, amif count mode) selects function of if counter or external gate counter 0 0 1 1
275 m pd17704, 17705, 17707, 17708, 17709 figure 18-4. configuration of fcg channel selection register name flag symbol b 3 0 b 2 0 b 1 f c g c h 1 b 0 f c g c h 0 address 20h read/write r/w fcg channel selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 1 0 0 0 0 fcg not used (general-purpose i/o port) p2a0/fcg0 pin p2a1/fcg1 pin setting prohibited fixed to 0 selects pin used for fcg 00 0 0 1 1 0 0 0 0
276 m pd17704, 17705, 17707, 17708, 17709 18.3 start/stop control block and if counter 18.3.1 configuration of start/stop control block and if counter figure 18-5 shows the configuration of the start/stop control block and if counter. the start/stop control block starts the frequency counter or detects the end of counting. the counter is started by the if counter control register. the end of counting is detected by the if counter gate status detection register. when the external gate counter function is used, however, the end of counting cannot be detected by the if counter gate status detection register. figure 18-6 shows the configuration of the if counter control register. figure 18-7 shows the configuration of the if counter gate status detection register. 18.3.2 and 18.3.3 describe the gate operation when the if counter function is selected and that when the external gate counter function is selected. the if counter is a 16-bit binary counter that counts up the input frequency when the if counter function or external gate counter function is selected. when the if counter function is selected, the frequency input to a selected pin is counted while the gate is opened by an internal gate signal. the frequency count is counted without alteration in the amif count mode. in the fmif counter mode, however, the frequency input to the pin is halved and counted. when the external gate counter function is selected, the internal frequency is counted while the gate is opened by the signal input to the pin. when the if counter counts up to ffffh, it remains at ffffh until reset. the count value is read by the if counter data register (ifc) via data buffer. the count value is reset by the if counter control register. figure 18-8 shows the configuration of the if counter data register. figure 18-5. configuration of start/stop control block and if counter start/stop control if counter (16 bits) 16 if counter data register (ifc) dbf ifcstrt flag ifcres flag ifcgostt flag gate signal frequency from gate time selection block 16 res
277 m pd17704, 17705, 17707, 17708, 17709 figure 18-6. configuration of if counter control register name flag symbol b 3 0 b 2 0 b 1 i f c s t r t b 0 i f c r e s address 23h read/write w if counter control 0 1 nothing is affected resets counter resets data of if counter and external gate counter nothing is affected resets counter fixed to 0 start if counter and external gate counter 0 1 power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 00 0 0 0
278 m pd17704, 17705, 17707, 17708, 17709 figure 18-7. configuration of if counter gate status detection register cautions 1. do not read the contents of the if counter data register (ifc) to the data buffer while the ifcgostt flag is set to 1. 2. the gate of the external gate counter cannot be opened or closed by the ifcgostt flag. use the ifcstrt flag to open or close the gate. name flag symbol b 3 0 b 2 0 b 1 0 b 0 i f c g o s t t address 21h read/write r if counter gate status detection 0 1 detects opening/closing of gate of frequency counter when if counter function is selected when external gate counter function is selected fixed to 0 power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 00 sets ifcstrt flag to 1 and is set to 1 until gate is closed sets ifcstrt flag to 1 and is set to 1 while gate is open, regardless of input of p2a0/fcg0 and p2a1/fcg1 pins
279 m pd17704, 17705, 17707, 17708, 17709 18.3.2 operation of gate when if counter function is selected (1) when gate time of 1, 4, or 8 ms is selected the gate is opened for 1, 4, or 8 ms from the rising of the internal 1-khz signal after the ifcstrt flag has been set to 1, as illustrated below. while this gate is open, the frequency input from a selected pin is counted by a 16-bit counter. when the gate is closed, the ifcg flag is cleared to 0. the ifcgostt flag is automatically set to 1 when the ifcstrt flag is set. (2) when gate is open if opening of the gate is selected by the ifcck1 and ifcck0 flags, the gate is opened as soon as its opening has been selected, as illustrated below. if the counter is started by using the ifcstrt flag while the gate is open, the gate is closed after undefined time. to open the gate, therefore, do not set the ifcstrt flag to 1. however, the counter can be reset by the ifcres flag. sets ifcck1 = ifcck0 = 1 gate is actually opened at this point. if g ate is opened while ifcgostt fla g is 1, it is closed after undefined time count period gate is closed after undefined time if ifcstrt flag is set during this period h internal 1 khz l open close gate the gate is opened or closed in the following two ways when opening the gate is selected as the gate time. gate is actually opened at this point count period (ifcgostt flag = 1) ifcstrt flag is set ifcgostt flag is set at this point end of counting ifgostt flag is cleared h internal 1 khz 1 ms gate time 4 ms 8 ms l open close
280 m pd17704, 17705, 17707, 17708, 17709 (a) resetting the gate to other than open by using ifcck1 and ifcck0 flags (b) unselect pin used by using ifcmd1 and ifcmd0 flags in this way, the gate remains open, and counting is stopped by disabling input from the pin. 18.3.3 gate operation when external gate counter function is selected the gate is opened from the rising to the next rising of the signal input to a selected pin after the ifcstrt flag has been set to 1, as illustrated below. while the gate is open, the internal frequency (1 khz, 100 khz, 900 khz) is counted by a 16-bit counter. the ifcgostt flag is set to 1 from the rising to the next rising of the external signal after the ifcstrt flag has been set. in other words, the opening or closing of the gate cannot be detected by the ifcg flag when the external gate counter function is selected. if reset and started while gate is open ifcck1 = ifcck0 = 1 count period resetting the gate to other than open by ifcck1 and ifcck0 flags open gate close gate open close sets ifcck1 = ifcck0 = 1 count period sets ifcmd1 = ifcmd0 = 0 (fcg) fmifc and amifc pins are unselected and count signal cannot be input h l open close external signal gate count period gate is opened at this point end of counting ifcgostt flag is 0 ifcstrt flag 1 h l open close external signal gate count period count period ifcstrt flag 1 gate is opened at this point end of counting ifcgostt flag is 0 ifcstrt flag 1
281 m pd17704, 17705, 17707, 17708, 17709 18.3.4 function and operation of 16-bit counter the 16-bit counter counts up the frequency input within selected gate time. the 16-bit counter can be reset by writing 1 to the ifcres flag of the if counter control register. once the 16-bit counter has counted up to ffffh, it remains at ffffh until it is reset. the following paragraphs (1) and (2) describe the operations when the if counter function is selected and when the external gate counter function is selected. the value of the if counter data register is read via data buffer. figure 18-8 shows the configuration and function of the if counter data register. (1) when if counter is selected the frequency input to the p1c0/fmifc or p1c1/amifc pin is counted while the gate is open. note, however, that the frequency input to the p1c0/fmifc is divided by two and counted. the relationship between count value x (decimal) and input frequencies (f fmifc and f amifc ) is shown below. ? fmifc f fmifc = x 2 (khz) t gate : gate time (1 ms, 4 ms, 8 ms) t gate ? amifc f amifc = x (khz) t gate : gate time (1 ms, 4 ms, 8 ms) t gate (2) when external gate counter (fcg) is selected the internal frequency is counted while the gate is opened by the signal input to the p2a1/fcg1 or p2a0/ fcg0 pin. the relationship between the count value x (decimal) and the gate width t gate of the input signal is shown below. t gate = x (ms) fr: internal frequency (1, 100, 900 khz) fr
282 m pd17704, 17705, 17707, 17708, 17709 figure 18-8. configuration of if counter data register data buffer dbf3 dbf2 name if counter data register symbol ifc peripheral address 43h dbf1 dbf0 b 3 b 2 b 1 b 0 b 6 b 5 b 4 b 10 b 9 b 8 b 7 b 13 b 12 b 15 b 14 b 11 peripheral register 0 transfer data valid data get can be executed put changes nothing 16 count value of frequency counter x 2 16 C1 (ffffh) if counter function ? fmif count mode of fmifc pin counts rising edge of signal input to p1c0/fmifc pin via 1/2 divider ? amif count mode of amifc pin counts rising edge of signal input to p1c1/amifc pin ? amif count mode of fmifc pin counts rising edge of signal input to p1c0/fmifc pin external gate counter function counts rising edge of internal reference frequency signal from rising edge to next rising edge of signal input to p2a0/fcg0 or p2a1/fcg1 pin once the if counter data register has counted up to ffffh, it remains at ffffh until the counter is reset.
283 m pd17704, 17705, 17707, 17708, 17709 18.4 using if counter the following sections 18.4.1 through 18.4.3 describe how to use the hardware of the if counter, a program example, and count error. 18.4.1 using hardware of if counter figure 18-9 shows the block diagram when the p1c0/fmifc and p1c1/amifc pins. as shown in the figure, the if counter uses an input pin with an ac amplifier, the dc component of the input signal must be cut with a capacitor. when the p1c0/fmifc or p1c1/amifc pin is selected for the if counter function, switch sw turns on, and the voltage level on each pin reaches about 1/2v dd . if the voltage has not risen to a sufficient intermediate level at this time, the if counter does not operate normally because the ac amplifier is not in the normal operating range. therefore, make sure that a sufficient wait time elapses after each pin has been specified to be used for the if counter until counting is started. figure 18-9. if count function block diagram of each pin to internal counter sw r c fmifc amifc external frequecny
284 m pd17704, 17705, 17707, 17708, 17709 18.4.2 program example of if counter a program example of the if counter is shown below. as shown in this example, make sure that a wait time elapses after an instruction that selects the p1c0/fmifc or p1c1/amifc pin for the if counter function has been executed until counting is started. this is because, as described in 18.4.1, the internal ac amplifier does not operate normally immediately after a pin has been selected for the if counter. example to count the frequency input to the p1c0/fmifc pin (fmif count mode) (gate time: 8 ms) initflg ifcmd1, not ifcmd0, ifcck1, not ifcck0 ; selects fmifc pin (fmif count mode), and sets gate time to 8 ms wait ; internal ac amplifier stabilization time set1 ifcres ; resets counter set1 ifcstrt ; starts counting loop: skt1 ifcg0stt ; detects opening or closing of gate br read ; branches to read: if gate is closed processing a br loop ; do not read data of if counter with this processing a read: get dbf, ifc ; reads value of if counter data register to data buffer 18.4.3 error of if counter the errors of the if counter include a gate time error and a count error. the following paragraphs (1) and (2) describe each of these errors. (1) gate time error the gate time of the if counter is created by dividing the 4.5-mhz clock. therefore, if the system clock is shifted from 4.5 mhz by +x ppm, the gate time is shifted by Cx ppm. (2) count error the if counter counts frequency by the rising edge of the input signal. if a high level is input to the pin when the gate is open, therefore, one excess pulse is counted. if the gate is closed, however, a count error due to the status of the pin does not occur. therefore, the count error is +1, C0.
285 m pd17704, 17705, 17707, 17708, 17709 18.5 using external gate counter 18.5.1 program example of external gate counter a program example of the external gate counter is shown below. example to use the p2a0/fcg0 pin as external gate input pin initflg not ifcmd1, not ifcmd0, ifcck1, not ifcck0 ; selects external gate counter function and sets gate time to 8 ms initflg not fcgch1, fcgch0 ; selects fcg0 pin as external gate input pin set1 ifcres ; resets counter set1 ifcstrt ; starts counting loop: skf1 ifcgostt ; detects opening or closing of gate br read ; branches to read: if gate is closed processing a ; do not read data of if counter with this processing a br loop read: get dbf, ifc ; reads value of if counter data register to data buffer 18.5.2 error of external gate counter the errors of the external gate counter include an internal frequency error and a count error. the following paragraphs (1) and (2) describe each of these errors. (1) internal frequency error the internal frequency of the external gate counter is created by dividing the 4.5-mhz clock. therefore, if the system clock is shifted from 4.5 mhz by +x ppm, the gate time is shifted by Cx ppm. (2) count error the external gate counter counts the frequency by the rising edge of the internal frequency. if the internal frequency is low when the gate is opened (when the signal input to the pin rises), one excess pulse is counted. if the gate is closed (when the signal rises next time), the excess pulse is not counted due to the count level of the internal frequency. therefore, the count error is +1, C0.
286 m pd17704, 17705, 17707, 17708, 17709 18.6 status at reset 18.6.1 at power-on reset the p1c0/fmifc, p1c1/amifc, p2a0/fcg0, and p2a1/fcg1 pins are set in the general-purpose input port mode. 18.6.2 at wdt&sp reset the p1c0/fmifc, p1c1/amifc, p2a0/fcg0, and p2a1/fcg1 pins are set in the general-purpose input port mode. 18.6.3 on execution of clock stop instruction the p1c0/fmifc and p1c1/amifc pins are set in the general-purpose input port mode. the p2a0/fcg0 and p2a1/fcg1 pins are set in the general-purpose i/o port mode, and retain the previous input or output status. 18.6.4 at ce reset the p1c0/fmifc and p1c1/amifc pins are set in the general-purpose input port mode. the p2a0/fcg0 and p2a1/fcg1 pins are set in the general-purpose i/o port mode, and retain the previous input or output status. 18.6.5 in halt status the p1c0/fmifc, p1c1/amifc, p2a0/fcg0, and p2a1/fcg1 pins retain the status immediately before the halt mode is set.
287 m pd17704, 17705, 17707, 17708, 17709 19. beep 19.1 outline of beep figure 19-1 outlines beep. beep outputs a clock of 1, 3, 4, or 6.7 khz from the p1d0/beep0 pin, and a clock of 4 khz, 3 khz, 200 hz, or 67 hz from the p1d1/beep1 pin. the duty factor of the beep output is 50%. figure 19-1. outline of beep p1d0/beep0 p1d1/beep1 p1dbio0 flag beep0sel flag beep0ck1 falg beep0ck0 falg p1dbio1 flag beep1sel flag beep1ck1 flag beep1ck0 flag i/o selection block output selection flag clock selection block i/o selection block output selection flag clock selection block output latch output latch clock generation block 1 khz 3 khz 4 khz 6.7 khz 67 hz 200 hz remarks 1. beep0ck1 and beep0ck0 (bits 1 and 0 of beep clock selection register: refer to figure 19-4 ) select the output frequency of beep0. 2. beep1ck1 and beep1ck0 (bits 3 and 2 of beep clock selection register: refer to figure 19-4 ) select the output frequency of beep1. 3. beep1sel and beep0sel (bits 1 and 0 of beep/general-purpose port pin function selection register: refer to figure 19-3 ) select general-purpose i/o port and beep. 4. p1dbio1 and p1dbio0 (bits 1 and 0 of port 1d bit i/o selection register: refer to figure 19-2 ) select the input or output mode of the port.
288 m pd17704, 17705, 17707, 17708, 17709 19.2 i/o selection block and output selection block the i/o selection block selects the input or output mode of the p1d0/beep0 and p1d1/beep1 pins by using the port 1d bit i/o selection register. set the pin to be used as a beep pin in the output mode. the output selection block sets the p1d0/beep0 and p1d1/beep1 pins in the general-purpose output port mode or beep output mode by using the beep/general-purpose port pin function selection register. figure 19-2 shows the configuration of the port 1d bit i/o selection register. figure 19-3 shows the configuration of the beep/general-purpose port pin function selection registerion. figure 19-2. configuration of port 1d bit i/o selection register name flag symbol b 3 p 1 d b i o 3 b 2 p 1 d b i o 2 b 1 p 1 d b i o 1 b 0 p 1 d b i o 0 address (bank15) 6ch read/write r/w port 1d bit i/o selection power-on reset wdt&sp reset ce reset clock stop at reset 0 1 0 0 0 0 0 0 0 0 0 1 sets p1d0/beep0 pin in input mode sets p1d0/beep0 pin in output mode. selects input or output port mode sets p1d1/beep1 pin in input mode sets p1d1/beep1 pin in output mode selects input or output port mode sets p1d2 pin in input mode sets p1d2 pin in output mode selects input or output port mode sets p1d3 pin in input mode sets p1d3 pin in output mode selects input or output port mode 0 1 0 1 retained retained
289 m pd17704, 17705, 17707, 17708, 17709 figure 19-3. configuration of beep/general-purpose port pin function selection register name flag symbol b 3 0 b 2 0 b 1 b e e p 1 s e l b 0 b e e p 0 s e l address 13h read/write r/w beep/general-purpose port pin function selection power-on reset wdt&sp reset ce reset clock stop at reset 000 0 0 0 0 0 0 0 0 1 uses p1d0/beep0 pin as general-purpose i/o port uses p1d0/beep0 pin for beep selects general-purpose i/o port or beep uses p1d1/beep1 pin as general-purpose i/o port uses p1d1/beep1 pin for beep selects general-purpose i/o port or beep fixed to 0 0 1
290 m pd17704, 17705, 17707, 17708, 17709 19.3 clock selection block and clock generation block the clock selection block selects the output frequency of beep1 and beep0 by using the beep clock selection register. the clock generation block generates the clock to be output to beep0 and beep1. the clock frequency generated is 1 khz, 3 khz, 4 khz, 6.7 khz, 67 hz, or 200 hz. figure 19-4. configuration of beep clock selection register name flag symbol b 3 b e e p 1 c k 1 b 2 b e e p 1 c k 0 b 1 b e e p 0 c k 1 b 0 b e e p 0 c k 0 address 14h read/write r/w beep clock selection power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 khz 3 khz 4 khz 6.7 khz sets output frequency of beep0 4 khz 3 khz 200 hz 67 hz sets output frequency of beep1 0 0 1 1 0 1 0 1 0 0 1 1
291 m pd17704, 17705, 17707, 17708, 17709 19.4 output waveform of beep the duty factor of the beep output waveform is 50%. example f = 3 khz f = 1 khz f = 200 hz f: output frequency of beep 166.7 s 166.7 s 500 s 2.5 ms 2.5 ms 500 s m m m m 19.5 status at reset 19.5.1 at power-on reset the p1d0/beep0 and p1d1/beep1 pins are set in the general-purpose input port mode. 19.5.2 at wdt&sp reset the p1d0/beep0 and p1d1/beep1 pins are set in the general-purpose input port mode. 19.5.3 on execution of clock stop instruction the p1d0/beep0 and p1d1/beep1 pins are set in the general-purpose i/o port mode, and retain the previous input or output status. 19.5.4 at ce reset the p1d0/beep0 and p1d1/beep1 pins are set in the general-purpose i/o port mode, and retain the previous input or output status. 19.5.5 in halt status the previous status is retained.
292 m pd17704, 17705, 17707, 17708, 17709 20. standby the standby function is used to reduce the current consumption of the device while the device is backed up. 20.1 outline of standby function figure 20-1 outlines the standby block. the standby function reduces the current consumption of the device by partly or totally stopping the device operation. the following three types of standby functions are available for selection as the application requires. ? halt function ? clock stop function ? device operation control function by ce pin the halt function reduces the current consumption of the device by stopping the cpu operation by using a dedicated instruction halt h. the clock stop function reduces the current consumption of the device by stopping the oscillation of the oscillation circuit by using a dedicated instruction stop s. the ce pin can be said to be one of the standby functions because it can be used to control the operation of the pll frequency synthesizer and to reset the device. figure 20-1. outline of standby block interrupt control block btm0cy p0d3/ad3 p0d2/ad2 p0d1/ad1 p0d0/ad0 input latch oscillation circuit x out x in halt control circuit halt h clock stop control circuit stop s cpu program counter alu system register control register instruction decoder
293 m pd17704, 17705, 17707, 17708, 17709 20.2 halt function 20.2.1 outline of halt function the halt function stops the operating clock of the cpu by executing the halt h instruction. when this instruction is executed, the program is stopped until the halt status is later released. therefore, the current consumption of the device in the halt status is reduced by the operating current of the cpu. the halt status is released by using basic timer 0 carry ff, interrupt, or port input (p0d). the release condition is specified by operand h of the halt h instruction. 20.2.2 halt status in the halt status, all the operations of the cpu are stopped. in other words, execution of the program is stopped at the halt h instruction. however, the peripheral hardware units continue the operation specified before execution of the halt h instruction. for the operation of each peripheral hardware unit, refer to 20.4 device operation in halt and clock stop status . 20.2.3 halt release condition figure 20-2 shows the halt release condition. the halt release condition is specified by 4-bit data specified by operand h of the halt h instruction. the halt status is released when the condition specified by 1 in operand h. when the halt status is released, program execution is started from the instruction after the halt h instruction. if the halt status is released by an interrupt, the operation to be performed after the halt status has been released differs depending on whether the interrupts are enabled (ei status) or disabled (di status) when an interrupt source (irqxxx = 1) is issued with the interrupt (ipxxx = 1) enabled. if two or more releasing conditions are specified, the halt status is released when one of the specified condition is satisfied. if 0000b is set as halt release condition h, no releasing condition is set. if the device is reset (by means of power- on reset, wdt&sp reset, or ce reset) at this time, the halt status is released. figure 20-2. halt release condition operand halt h (4 bits) b 3 b 2 b 1 b 0 0 1 released when high level is input to port 0d released when basic timer 0 carry ff is set to 1 undefined (fix this bit to 0.) released when interrupt is accepted not released even if condition is satisfied released if condition is satisfied sets halt status releasing condition
294 m pd17704, 17705, 17707, 17708, 17709 20.2.4 releasing halt by input port (p0d) the halt releasing condition using an input port is specified by the halt 0001b instruction. when the halt releasing condition using an input port is specified, the halt status is released if a high level is input to one of the p0d0 through p0d3 pins. the p0d0 through p0d3 pins are multiplexed with the a/d converter input pins ad0 through ad3, and the halt status is not released when these pins are used as a/d converter input pins. an example is given below. ? to use as key matrix the p0d0 through p0d3 pins are general-purpose input port pins which can be set in the input or output mode in 1-bit units and can be connected to an internal pull-down resistor. if connection of the internal pull-down resistor is specified by software, an external resistor can be eliminated as shown in this example (the internal- pull down resistor is connected at power-on reset). the halt 0001b instruction is executed after the general-purpose output ports for key source signal are made high. note that if an alternate switch is used as shown by switch a in the above figure, the halt status is released immediately because a high level is input to the p0d0/ad0 pin while switch a is closed. p0d3/ad3 p0dpld3 flag p0d2/ad2 p0d1/ad1 p0d0/ad0 switch a general-purpose output port latch
295 m pd17704, 17705, 17707, 17708, 17709 20.2.5 releasing halt status by basic timer 0 carry ff releasing the halt status by using the basic timer 0 carry ff is specified by the halt 0010b instruction. when releasing the halt status by the basic timer 0 carry ff is specified, the halt status is released as soon as the basic timer 0 carry ff has been set to 1. the basic timer 0 carry ff corresponds to the btm0cy flag on a one-to-one basis and is set at fixed time intervals (100, 50, 20, or 10 ms). therefore, the halt status can be released at fixed time intervals. example to release halt status every 100 ms to execute processing a hlttmr dat 0010b ; symbol definition initflg not btm0ck1, not btm0ck0 ; sets time interval of basic timer 0 to 100 ms loop: halt hlttmr ; specifies setting of basic timer 0 carry ff as halt releasing condition skt1 btmocy ; embedded macro br loop ; branches to loop if btm0cy flag is not set processing a ; executes processing a if carry occurs br loop 20.2.6 releasing halt status by interrupt releasing the halt status by an interrupt is specified by the halt 1000b instruction. when releasing the halt status by an interrupt is specified, the halt status is released as soon as the interrupt has been accepted. many interrupt sources are available as described in 12. interrupts. which interrupt source is used to release the halt status must be specified in advance in software. to accept an interrupt, each interrupt request must be issued from each interrupt source and each interrupt must be enabled (by setting the corresponding interrupt enable flag). therefore, the interrupt is not accepted even if the interrupt request is issued, and the halt status is not released. when the halt status is released by accepting an interrupt, the program flow branches to the vector address of the interrupt. when the reti instruction is executed after interrupt servicing, the program flow is restored to the instruction after the halt instruction. if all the interrupts are disabled (di status), the halt status is released by enabling an interrupt (ipxxx = 1) and issuing an interrupt source (irqxxx = 1), and the flow of the program goes to the instruction after the halt instruction.
296 m pd17704, 17705, 17707, 17708, 17709 example releasing halt status by timer 0 and int0 pin interrupts in this example, the halt status is released and processing b is executed when timer 0 interrupt is accepted. and processing a is executed when int0 pin interrupt is accepted. each time the halt status has been released, processing c is executed. hltint dat 1000b ; symbol definition start: ; address 0000h br main ;*** interrupt vector address *** nop ; si01 nop ; si00 nop ; timer3 nop ; timer2 nop ; timer1 br inttm0 ; branches to timer 0 interrupt processing nop ; int4 nop ; int3 nop ; int2 nop ; int1 br int0 ; branches to int0 interrupt processing nop ; ce down edge int0: ; int0 pin interrupt vector address (000bh) processing a ; int0 pin interrupt processing ei reti intmm0: processing b ; timer 0 interrupt processing ei reti main: initflg not tmock1, tm0ck0 ; sets timer 0 count clock to 100 m s mov dbf1, #0 mov dbf0, #0ah put tm0m,dbf ; sets time interval of timer 0 interrupt to 1 ms set2 tm0res, tm0en ; resets and starts timer 0 set2 iptm0, ip0 ; enables int0 and timer 0 interrupts loop: processing c ; main routine processing ei ; enables all interrupts halt hltint ; specifies releasing halt status by interrupt ;<1> br loop if the int0 pin interrupt request and timer 0 interrupt request are issued simultaneously in the halt status, processing a for the int0 pin, which has the higher hardware priority, is executed. after execution of processing a and when reti is executed, the program branches to the br loop instruction of <1>. however, the br loop instruction is not executed, and timer 0 interrupt is immediately accepted. when the reti instruction is executed after processing b of timer 0 interrupt has been executed, the br loop instruction is executed.
297 m pd17704, 17705, 17707, 17708, 17709 caution to reset the interrupt request flag (irqxxx) once before the halt instruction is executed, insert a nop instruction (or one or more other instructions) between the halt instruction and the instruction that resets the interrupt request flag (irqxxx) as shown below. if a nop instruction (or one or more other instructions) is not inserted, the interrupt request flag is not reset, and therefore, the halt status is released immediately. example : : ; irqxxx is set at certain timing : clr1 irq ; resets irqxxx flag once nop ; resets irqxxx flag at this timing ; unless this period is missing, the irqxxx flag is not reset, ; and the next halt instruction is immediately released halt 1000b ;
298 m pd17704, 17705, 17707, 17708, 17709 20.2.7 if two or more releasing conditions are specified at same time if two or more halt releasing conditions are specified at same time, the halt status is released when one of the conditions is satisfied. the following program example shows how the releasing conditions are identified if two or more conditions are satisfied at the same time. example hltint dat 1000b hltbtm dat 0010b hltp0d dat 0001b p0d mem 0.73h start: br main ;*** interrupt vector address *** nop ; si01 nop ; si00 nop ; timer3 nop ; timer2 nop ; timer1 nop ; timer0 nop ; int4 nop ; int3 nop ; int2 nop ; int1 br int0 ; branches to int0 interrupt processing nop ; ce down edge int0: ; int0 pin interrupt vector address (000bh) processing a ; int0 pin interrupt processing ei reti btmoup: ; timer carry ff processing processing b ret p0dp: ; p0d input processing processing c ret main: initflg not btm0ck1, not btm0ck0 ; selects 100 ms as clock of basic timer 0 set1 ip0 ; enables int0 pin interrupt ei loop: halt hltint or hltbtm or hltp0c ; selects interrupt, timer carry ff, and p0d input as halt releasing conditions skf1 btm0cy ; detects btm0cy flag call btm0up ; timer carry ff processing if flag is set to 1 skf p0d, 1111b ; detects p0d input call p0dp ; port input processing if p0d is high br loop
299 m pd17704, 17705, 17707, 17708, 17709 in the above example, three halt status releasing conditions, int0 pin interrupt, 100-ms basic timer 0 carry ff, and port 0d input, are specified. to identify which condition has released the halt status, a vector address (interrupt), btm0cy flag (timer carry ff), and port register (port input) are detected. to use two or more releasing conditions, the following two points must be noted. ? when the halt status is released, all the specified releasing conditions must be detected. ? the releasing condition with the higher priority must be detected first. 20.3 clock stop function 20.3.1 outline of clock stop function the clock stop function stops the oscillation circuit of a 4.5-mhz crystal resonator by executing the stop s instruction (clock stop status). therefore, the current consumption of the device is reduced to 30 m a max. 20.3.2 clock stop status in the clock stop status, all the device operations of the cpu and peripheral hardware units are stopped because the generation circuit of the crystal resonator is stopped. for the operations of the cpu and peripheral hardware units, refer to 20.4 device operation in halt and clock stop status . in the clock stop status, the power failure detection circuit does not operate even if the supply voltage v dd of the device is raised to 2.2 v. therefore, the data memory can be backed up at a low voltage. for the power failure detection circuit, refer to 21. reset . 20.3.3 releasing clock stop status figure 20-3 shows the stop status releasing conditions. the stop status releasing condition is specified by 4-bit data specified by operand s of the stop s instruction. the stop status is released when the condition specified by 1 in operand s is satisfied. when the stop status has been released, a halt period which is half the time (t set /2) specified by the basic timer 0 clock selection register as oscillation circuit stabilization wait time has elapsed, and the program execution is started from the instruction next to the stop s instruction. if releasing the stop status by an interrupt is specified, however, the program operation after the stop status has been released differs depending on whether the interrupt is enabled (ei status) or disabled (di status) when an interrupt source is issued (irqxxx = 1) with the interrupt enabled (ipxxx = 1). if all the interrupts are enabled (ei status), the stop status is released when the interrupt is enabled (ipxxx = 1) and the interrupt source is issued (irqxxx = 1), and the program flow returns to the instruction next to the stop instruction. if all the interrupts are disabled (di status), the stop status is released when the interrupt is enabled (ipxxx = 1) and the interrupt resource is issued (irqxxx = 1), and the program flow returns to the instruction next to the stop instruction. if two or more releasing conditions are specified at one time, and if one of the conditions is satisfied, the stop status is released. if 0000b is specified as stop releasing condition s, no releasing condition is satisfied. if the device is reset at this time (by means of power-on reset, or ce reset), the stop status is released.
300 m pd17704, 17705, 17707, 17708, 17709 figure 20-3. stop releasing conditions operand stop s (4 bits) b 3 b 2 b 1 b 0 0 1 releases when high level is input to port 0d undefined (fix this bit to 0.) undefined (fix this bit to 0.) released by interrupt of falling edge of int0 through int4 pins and ce pin not released even if condition is statisfied released if condition is satisfied specifies stop status releasing condition the stop s instruction is executed as a nop instruction when the ce pin rises and when the ce reset counter operates. the operating status of the ce reset counter can be detected by the cecntstt flag (for the ce reset counter, refer to 21. reset ). 20.3.4 releasing clock stop status by high level input of port 0d figure 20-4 illustrates how the clock stop status is released by the high level input to port 0d. figure 20-4. releasing clock stop status by high level input of port 0d v dd p0d x out 5 v 0 v h l 2.2 v stop s instruction starts from instruction next to stop s oscillation stops t set /2 halt period t set : basic timer 0 setting time 20.3.5 cautions on releasing clock stop status for the cautions on releasing the clock stop status, refer to (2) releasing from clock stop status in 21.4.4 cautions on raising supply voltage v dd .
301 m pd17704, 17705, 17707, 17708, 17709 20.4 device operation in halt and clock stop status table 20-1 shows the operations of the cpu and peripheral hardware units in the halt and clock stop status. in the halt status, all the peripheral hardware units continue the normal operation until instruction execution is stopped. in the clock stop status, all the peripheral hardware units stop operation. the control registers that control the operations of the peripheral hardware units operate normally (not initialized) in the halt status, but are initialized to specified values when the clock stop instruction is executed. in other words, all peripheral hardware continues the operation specified by the control register in the halt status, and the operation is determined by the initialized value of the control register in the clock stop status. for the values of the control registers in the clock stop status, refer to 8. register file (rf) . table 20-1. device operation in halt and clock stop status peripheral hardware status halt clock stop program counter stops at address of halt instruction stops at address of stop instruction system register retained retained peripheral register retained partly initialized note 1 control register retained partly initialized note 1 timer normal operation operation stops pll frequency synthesizer normal operation note 2 operation stops a/d converter normal operation operation stops d/a converter normal operation stops operation and used as general- purpose output port serial interface stops operation when internal clock (master) stops operation and used as general- is selected and continues operation when purpose i/o port external clock (slave) is selected frequency counter normal operation stops operation and used as general- purpose input port beep output normal operation stops operation and used as general- purpose i/o port general-purpose i/o port normal operation retained general-purpose input port normal operation input port general-purpose output port normal operation retains output latch notes 1. for the value to which these registers are initialized, refer to 5. system register (sysreg) and 8. register file (rf) . 2. the pll frequency synthesizer is automatically disabled by the low level input to the ce pin. 20.5 cautions on processing of each pin in halt and clock stop status the halt status is used to reduce the current consumption when, say, only the watch is used. the clock stop function is used to reduce the current consumption of the device to only use the data memory. therefore, the current consumption must be reduced as much as possible in the halt status or clock stop status. at this time, the current consumption significantly varies depending on the status of each pin, and the points shown in table 20-2 must be noted.
302 m pd17704, 17705, 17707, 17708, 17709 table 20-2. status of each pin in halt and clock stop status and cautions (1/2) pin function pin symbol status of each pin and cautions on processing halt status clock stop status general- port 0a p0a3/sda purpose p0a2/scl i/o port p0a1/sck0 p0a0/so0 port 0b p0b3/si0 p0b2/sck1 p0b1/so1 p0b0/si1 port 0c p0c3-p0c0 port 1d p1d3 p1d2 p1d1/beep1 p1d0/beep0 port 2a p2a2 p2a1/fcg1 p2a0/fcg0 port 2b p2b3-p2b0 port 2c p2c3-p2c0 port 2d p2d2-p2d0 port 3a p3a3-p3a0 port 3b p3b3-p3b0 port 3c p3c30p3c0 port 3d p3d3-p3d0 general- port 0d p0d3/ad3 purpose | input port p0d0/ad0 port 1a p1a3/int4 p1a2/int3 p1a1 p1a0/tm0g port 1c p1c3/ad5 p1c2/ad4 p1c1/amifc p1c0/fmifc general- port 1b p1b3 purpose p1b2/pwm2 output port | p1b0/pwm0 retains status before halt (1) when specified as output pin current consumption increases if pin is externally pulled down while it outputs high level, or externally pulled up while it outputs low level. exercise care in using n-ch open- drain output (p0a3, p0a2, p1b3 through p1b0) (2) when specified as input pin current consumption increases due to noise if pin is floated (3) port 0d (p0d3/ad3 through p0d0/ ad0) current consumption increases if pin is externally pulled up because it is provided with pull-down resistor selectable by software (4) port 1c (p1c3/ad5, p1c2/ad4, p1c1/amifc, p1c0/fmifc) when p1c1/amifc or p1c0/fmifc pin is used for if counter, current consumption increases because internal amplifier operates all port pins are set in general-purpose port mode (except p0d3/ad3 through p0d0/ad0, p1a3/int4, p1a2/int3, p1c3/ad5, and p1c2/ad4) input or output mode of general-purpose i/o port set before clock stop status is retained. (1) when specified as general-purpose output port current consumption increases due to noise if pin is floated (2) when specified as general-purpose input port current consumption does not increase due to noise even if pin is floated (3) p1a3/int4, p1a2/int3 set as interrupt pin and current consumption increases due to external noise if pin is floated (4) p0d3/ad3 through p0d0/ad0, p1c3/ad5, p1c2/ad4 pin used for a/d converter is retained as is. pull-down resistor of p0d3 through p0d0 pin retains previous status specified as general-purpose output port. output contents are retained as is. if pin is externally pulled down while it outputs high level or externally pulled up while it outputs low level, current consumption increases
303 m pd17704, 17705, 17707, 17708, 17709 table 20-2. status of each pin in halt and clock stop status and cautions (2/2) pin function pin symbol status of each pin and cautions on processing halt status clock stop status external interrupt int4-int0 current consumption increases due to noise if pin is floated pll frequency vcol synthesizer vcoh eo0 eo1 crystal oscillation x in circuit x out 20.6 device operation control function of ce pin the ce pin controls the following functions by the input level and rising edge of the signal input from an external source. ? pll frequency synthesizer ? interrupt by falling edge of ce pin ? resetting of device 20.6.1 controlling operation of pll frequency synthesizer the pll frequency synthesizer can operate only when the ce pin is high. it is automatically disabled when the ce pin is low. when the synthesizer is disabled, the vcoh and vcol pins are internally pulled down, and the eo0 and eo1 pins are floated. for details, refer to 17.5 pll disabled status . the pll frequency synthesizer can be disabled in software even when the ce pin is high. 20.6.2 controlling interrupt by falling edge input of ce pin an interrupt can be generated by the falling edge of the ce pin. for details, refer to 12. interrupts . current consumption increases during pll operation. when pll is disabled, pin is in following status: vcoh, vcol : internally pulled down eo1, eo0 : floated pll is automatically disabled if ce pin goes low pll is disabled vcoh, vcol : internally pulled down eo1, eo0 : floated current consumption changes due to oscillation waveform of crystal oscillation circuit. the higher oscillation amplitude, the lower current consumption. oscillation amplitude must be evaluated because it is influenced by crystal resonator or load capacitor used x in pin is internally pulled down, and x out pin outputs high level
304 m pd17704, 17705, 17707, 17708, 17709 20.6.3 resetting device the device can be reset (ce reset) by raising the ce pin. the device can also be reset as follows: ? power-on reset on application of supply voltage v dd ? watchdog timer reset for software hang-up detection and stack overflow/underflow reset ? reset by reset pin for details, refer to 21. reset . 20.6.4 signal input to ce pin the ce pin does not accept a low level or high level of less than 167 m s to prevent malfunctioning due to noise. the level of the signal input to the ce pin can be detected by the ce pin status detection flag of the ce pin interrupt request register (rf address 3fh). figure 20-5 shows the relationship between the input signal and ce flag. figure 20-5. relationship between input signal of ce pin and ce flag ce pin ce flag h l 1 0 less than 167 s 167 s pll can operate pll disabled pll disabled note ce reset is effected in synchronization with next basic timer 0 carry ff (when ce reset count register is ?? less than 167 s 167 s ce reset m m m m note unless the pll mode selection register and pll reference frequency selection register are rewritten by software, the pll disabled status is retained.
305 m pd17704, 17705, 17707, 17708, 17709 20.6.5 configuration and function of ce pin interrupt request register the ce pin interrupt request register detects the input signal level of the ce pin. figure 20-6 shows the configuration of the ce pin interrupt request register. figure 20-6. configuration of ce pin interrupt request register name flag symbol b 3 c e b 2 0 b 1 c e c n t s t t b 0 i r q c e address 3fh read/write r note ce pin interrupt request power-on reset wdt&sp reset ce reset clock stop at reset u u u u 00 0 0 0 0 0 r r 0 1 no interrupt request interrupt request sets interrupt request issuance status of ce pin stops operates detects status of ce reset counter low level is input high level is input detects status of ce pin fixed to 0 0 1 0 1 u: undefined r: retained note irqce is a r/w flag.
306 m pd17704, 17705, 17707, 17708, 17709 21. reset 21.1 outline of reset the reset function is used to initialize the device. the m pd17709 can be reset in the following ways: ? ce reset ? power-on reset ? reset by reset pin ? wdt&sp reset figure 21-1. configuration of reset block x out x in v dd reset ce stop s instruction voltage detection circuit falling detection circuit rising detection circuit btm0cy flag read power failure detection block timer ff block divider selector basic timer 0 carry r s q basic timer 0 carry disable ff power-on clear signal (poc) reset control circuit stop instruction ce reset timer carry counter watchdog timer stack overflow/underflow detection block ce reset signal wdt&sp reset signal
307 m pd17704, 17705, 17707, 17708, 17709 21.2 ce reset ce reset is effected by raising the ce pin. when the ce pin goes high, the next rising edge of the basic timer 0 carry ff setting pulse is counted. when the count value coincides with the value set to the ce reset timer carry counter register (1 to 15 counts), the reset signal is generated. when ce reset is effected, the program counter, stack, system registers, and some of the control registers are initialized to the initial values, and program execution is started from address 0000h. for the initial value of each register, refer to the description of each register . figure 21-2. configuration of ce reset timer carry counter register name flag symbol b 3 c e c n t 3 b 2 c e c n t 2 b 1 c e c n t 1 b 0 c e c n t 0 address 06h read/write r/w ce reset timer carry counter power-on reset wdt&sp reset ce reset clock stop at reset 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 setting prohibited 1 count 2 counts 3 counts 4 counts 5 counts 6 counts 7 counts 8 counts 9 counts 10 counts 11 counts 12 counts 13 counts 14 counts 15 counts sets number of counts of timer carry counter for ce reset 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 retained retained
308 m pd17704, 17705, 17707, 17708, 17709 the operation of ce reset differs depending on whether the clock stop instruction is used or not. this difference is described in 21.2.1 and 21.2.2 below. 21.2.3 describes the points to be noted when ce reset is effected. 21.2.1 ce reset without clock stop (stop s) instruction figure 21-2 shows the operation. when the ce pin has gone high, the ce reset timer carry counter starts counting at the rising edge of the basic timer 0 carry ff setting pulse. figure 21-3. ce reset operation without clock stop instruction (1/2) (a) normal operation ? when n is set to ce reset timer carry counter ? when 1 is set to ce reset timer carry counter v dd ce x out btm0cy flag setting pulse ce reset timer carry counter set value of ce reset timer carry counter ce reset signal 5 v 0 v h l h l h l h l h h l l t set 0 1 2 3 nC2 nC1 n 0 n ce reset v dd ce x out btm0cy flag setting pulse ce reset timer carry counter set value of ce reset timer carry counter ce reset signal ce reset 5 v 0 v h l h l h l h l h h l l t set 01 0 1
309 m pd17704, 17705, 17707, 17708, 17709 figure 21-3. ce reset operation without clock stop instruction (2/2) (b) if status of ce pin changes while ce counter operates at this time, the ce reset timer carry counter status is not affected. 21.2.2 ce reset with clock stop (stop s) instruction used figure 21-4 shows the operation. when the clock stop instruction is used, the clock stop signal is output when the stop s instruction is executed, and oscillation is stopped and the device operation is stopped. when the ce pin goes high, the clock stop status is released, and oscillation is started (high level input of p0d or int pin interrupt can also be used as the clock stop status releasing conditions. for details, refer to 20. standby ). if the basic timer 0 carry ff setting pulse goes high after the ce pin has gone high, the halt status is released, and program execution is started from address 0 (ce reset). as the set time (t set ) of the basic timer 0 carry ff setting pulse, the value immediately before the clock stop instruction is executed is retained. because the set value of the ce reset timer carry counter is initialized to 1, ce reset is effected t set /2 after the ce pin has gone high. v dd ce x out btm0cy flag setting pulse ce reset timer carry counter set value of ce reset timer carry counter ce reset signal 5 v 0 v h l h l h l h l h h l l t set 0 1 2 3 nC2 nC1 n 0 n ce reset
310 m pd17704, 17705, 17707, 17708, 17709 figure 21-4. ce reset operation with clock stop instruction 21.2.3 cautions on ce reset because ce reset is effected regardless of the instruction under execution, the following points (1) and (2) must be noted. (1) time to execute timer processing such as watch when creating a watch program by using the basic timer 0 carry, the processing time of the program must be kept to within a specific time. for details, refer to 13.2.6 cautions on using basic timer 0 . (2) processing of data and flags used in program exercise care in rewriting the data and flags whose contents must not be changed even when ce reset is effected, such as security code. an example is shown below. v dd ce x out btm0cy flag setting pulse ce reset timer carry counter set value of ce reset timer carry counter normal operation 5 v 0 v h l h l h l h l h h l l t set n1 1 0 clock stop status halt status t set /2 stop s instruction clock stop status released. oscillation starts ce reset program execution starts from address 0 ce reset signal
311 m pd17704, 17705, 17707, 17708, 17709 example 1. r1 mem 0.01h ; 1st digit of key input data of security code r2 mem 0.02h ; 2nd digit of key input data of security code r3 mem 0.03h ; 1st digit data when security code is changed r4 mem 0.04h ; 2nd digit data when security code is changed m1 mem 0.11h ; 1st digit of current security code m2 mem 0.12h ; 2nd digit of current security code start: key input processing r1 contents of key a ; security code input wait mode r2 contents of key b ; substitutes contents of pressed key to r1 and r2 set2 cmp, z ; <1> ; compares security code and input data sub r1, m1 sub r2, m2 skt1 z br error ; input data differs from security code main: key input processing r3 contents of key c ; security code rewriting mode r4 contents of key d ; substitutes contents of pressed key to r3 and r4 st m1, r3 ; <2> ; rewrites security code st m2, r4 ; <3> br main error: must not operate suppose the security code is 12h in the program in example 1. the contents of data memory addresses m1 and m2 are 1h and 2h, respectively. if ce reset is effected, the contents of key input and security code 12h are compared in <1>. if the two are the same, the normal processing is performed. if the security code is changed in the main processing, the new code is written to m1 and m2 in <2> and <3>. suppose the security code is changed to 34h. then 3h and 4h are written to m1 and m2 in <2> and <3>. if ce reset is effected as soon as <2> has been executed, program execution is started from address 0000h, without <3> being executed. consequently, the security code is set to 32h, making it impossible to clear the security system. in this case, create the program shown in example 2.
312 m pd17704, 17705, 17707, 17708, 17709 example 2. r1 mem 0.01h ; 1st digit of key input data of security code r2 mem 0.02h ; 2nd digit of key input data of security code r3 mem 0.03h ; 1st digit data when security code is changed r4 mem 0.04h ; 2nd digit data when security code is changed m1 mem 0.11h ; 1st digit of current security code m2 mem 0.12h ; 2nd digit of current security code change flg 0.13h.0 ; 1 while security code is changed start: key input processing r1 contents of key a ; security code input wait mode r2 contents of key b ; substitutes contents of pressed key to r1 and r2 skt1 change ; <4> ; if change flag is 1 br security_chk st m1, r3 ; rewrites m1 and m2 st m2, r4 clr1 change security_chk: set2 cmp, z ; <1> ; compares security code and input data sub r1, m1 sub r2, m2 skt1 z br error ; input data differs from security code main: key input processing r3 contents of key c ; security code rewriting mode r4 contents of key d ; substitutes contents of pressed key to r3 and r4 set1 change ; <5> ; until security code is changed, ; sets change flag to 1 st m1, r3 ; <2> ; rewrites security code st m2, r4 ; <3> clr1 change ; if security code has been changed, ; sets change flag to 0 br main error: must not operate the program in example 2 sets the change flag to 1 in <5> before the security code is rewritten in <2> and <3>. therefore, even if ce reset is effected before <3> is executed, the security code is rewritten in <4>.
313 m pd17704, 17705, 17707, 17708, 17709 21.3 power-on reset power-on reset is effected by raising the supply voltage v dd of the device from a specific level (called a power- on clear voltage). if supply voltage v dd is lower than the power-on clear voltage, a power-on clear signal (poc) is output from the voltage detection circuit shown in figure 21-1. when the power-on clear signal is input to the reset control circuit, the crystal oscillation circuit is stopped and consequently, the device operation is stopped. at this time, the program counter, stack, system registers, and control registers are initialized (for the initial value, refer to the description of each register ). if supply voltage v dd exceeds the power-on clear voltage, the power-on clear signal is deasserted, crystal oscillation is started, and the device waits for release of the halt status by the basic timer 0 carry which has been initialized to 100 ms. program execution is started from address 0 at the rising edge of the basic timer 0 carry ff setting signal 50 ms after the supply voltage has exceeded the power-on clear voltage. normally, the power-on clear voltage is 3.5 v, but it is 2.2 v in the clock stop status. the operations of power-on reset are described in 21.3.1 and 21.3.2. the operation when supply voltage v dd is raised from 0 v is described in 21.3.3. caution although it is stated that the normal power-on clear voltage is 3.5 v (max.) and that in the clock stop status is 2.2 v (max.), the actual power-on clear voltage does not exceed these maximum values. figure 21-5. operation of power-on reset v dd ce power-on clear signal x out btm0cy flag setting pulse 5 v 0 v h l h l h h l l power-on clear voltage power-on clear released oscillation starts program starts from address 0 50 ms halt status device operation stops normal operation
314 m pd17704, 17705, 17707, 17708, 17709 21.3.1 power-on reset during normal operation figure 21-6 (a) shows the operation. as shown, the power-on clear signal is output and the device operation is stopped if the supply voltage v dd drops below 3.5 v, regardless of the input level of the ce pin. if v dd rises beyond 3.5 v again, program execution starts from address 0000h after a halt of 50 ms. normal operation means operation without the clock stop instruction, and includes the halt status set by the halt instruction. 21.3.2 power-on reset in clock stop status figure 21-6 (b) shows the operation. as shown, the power-on clear signal is output and the device operation is stopped when supply voltage v dd drops below 2.2 v. however, it does not appear that device operation has changed because the device is in the clock stop status. if v dd rises beyond 3.5 v, program execution starts from address 0000h after a halt of 50 ms. 21.3.3 power-on reset when supply voltage v dd rises from 0 v figure 21-6 (c) shows the operation. as shown, the power-on clear signal is output until supply voltage v dd rises from 0 v to 3.5 v. when v dd exceeds the power-on clear voltage, the crystal oscillation circuit starts operating, and program execution starts from address 0000h after a half of 50 ms.
315 m pd17704, 17705, 17707, 17708, 17709 figure 21-6. power-on reset and supply voltage v dd (a) normal operation (including halt status) v dd ce power-on clear signal x out 5 v 3.5 v 0 v h l h l h l power-on clear voltage normal operation device operation stops halt status 50 ms power-on clear released oscillation starts program starts from address 0 (c) if supply voltage v dd rises from 0 v v dd ce power on clear signal x out 5 v 3.5 v 2.2 v 0 v h l h l h l power-on clear voltage normal operation stop s instruction clock stop device operation stops halt status 50 ms power-on clear released oscillation starts program starts from address 0 (b) in clock stop status v dd ce power-on clear signal x out 5 v 3.5 v 0 v h l h l h l power-on clear voltage device operation stops halt status 50 ms power-on clear released oscillation starts program starts from address 0
316 m pd17704, 17705, 17707, 17708, 17709 21.4 relationship between ce reset and power-on reset on the first application of supply voltage v dd , power-on reset and ce reset are performed at the same time. the reset operations at this time are described in 21.4.1 through 21.4.3. 21.4.4 describes the points to be noted when raising supply voltage v dd . 21.4.1 if v dd pin and ce pin go high at the same time figure 21-7 (a) shows the operation. at this time, the program starts from address 0000h because of power-on reset. 21.4.2 if ce pin rises in forced halt status set by power-on reset figure 21-7 (b) shows the operation. at this time, the program starts from address 0000h because of power-on reset, in the same manner as 21.4.1. 21.4.3 if ce pin rises after power-on reset figure 21-7 (c) shows the operation. at this time, the program starts from address 0000h because of power-on reset, and the program starts from address 0000h again at the rising edge of the next basic timer 0 carry ff setting signal because of ce reset.
317 m pd17704, 17705, 17707, 17708, 17709 figure 21-7. relationship between power-on reset and ce reset (a) when v dd and ce pin rise at the same time (b) if ce pin rises in halt status (c) if ce pin rises after power-on reset v dd ce btm0cy flag setting pulse 5 v 3.5 v 0 v h l h l power-on clear voltage opera- tion stops halt status 50 ms normal operation power-on reset program starts ce reset program starts (if ce reset timer carry counter is set to 1) v dd ce btm0cy flag setting pulse 5 v 3.5 v 0 v h l h l power-on clear voltage opera- tion stops halt status 50 ms normal operation power-on reset program starts v dd ce btm0cy flag setting pulse 5 v 3.5 v 0 v h l h l power-on clear voltage opera- tion stops halt status 50 ms normal operation power-on reset program starts
318 m pd17704, 17705, 17707, 17708, 17709 21.4.4 cautions on raising supply voltage v dd the following points (1) and (2) must be noted when raising supply voltage v dd . (1) to raise supply voltage v dd from level lower than power-on clear voltage supply voltage v dd must be raised once to a level higher than 3.5 v. figure 21-8 illustrates this. as shown in the figure, if a voltage less than 3.5 v is applied on application of v dd in a program that backs up v dd at 2.2 v by using the clock stop instruction, the power-on clear signal remains output, and the program is not executed. at this time, the output ports of the device output undefined values, increasing the current consumption in some cases. consequently, the backup time when the device is backed up by batteries is substantially shortened. figure 21-8. cautions on raising v dd v dd btm0cy flag setting pulse x out 5 v 3.5 v 2.2 v 0 v h l h l power-on clear signal h l power-on clear voltage operation stops halt status 50 ms because output ports are undefined during this period, current consumption may increase. power-on reset pro g arm starts opera- tion stops normal operation back up initialize during this period and then execute clock stop instruction stop s instruction
319 m pd17704, 17705, 17707, 17708, 17709 (2) releasing from clock stop status if the device is released from the backup status when supply voltage v dd is backed up at 2.2 v by using the clock stop status, v dd must be raised to 3.5 v or more within t set /2 after the clock stop status has been released by int pin interrupt or high level input to port 0d. as shown in figure 21-9, the device is released from the clock stop status by means of ce reset. however, because the power-on clear voltage is changed to 3.5 v t set /2 after the clock stop status has been released, power-on reset is effected unless v dd is 3.5 v or higher. the same applies when v dd is raised. figure 21-9. releasing from clock stop status p0d btm0cy flag setting pulse x out 5 v 3.5 v 2.2 v 0 v 0 v h l h l power-on clear signal h l power-on clear voltage backup in clock stop status halt status t set /2 power-on clear voltage changes to 3.5 v at this point. therefore, v dd must be 3.5 v or higher before this point. normal operation backup stop s instruction h v dd program starts power-on clear voltage changes to 2.2 v at this point. therefore, v dd must be 3.5 v or higher before this point. t set : basic timer 0 setting time
320 m pd17704, 17705, 17707, 17708, 17709 21.5 reset by reset pin the device is reset by the reset pin in the following cases: ? to reset the device at voltage higher than power-on clear voltage ? external reset input in case of software hang-up caution if the device is reset by the reset pin during program execution, the data in the data memory may be corrupted. therefore, be careful when resetting with the reset pin. the reset operation is the same as that performed at power-on reset. when a low level is input to the reset pin, an internal reset signal is generated, the crystal oscillation circuit is stopped, and the device stops operation. at this point, the program counter, stack, system registers, and control registers are initialized (for the initial value, refer to the description of each register ). when the reset pin is raised next time, the crystal oscillation is started, and the device waits to be released from the halt wait status by the basic timer 0 carry which has been initialized to a 100-ms cycle. the program starts from address 0 at the rising edge of the basic timer 0 carry ff setting signal 50 ms after a high level has been input to the reset pin. because the m pd17709 has a power-on reset function, connect the reset pin to v dd via resistor if the reset pin is not used for the above application. figure 21-10. reset operation by reset pin v dd reset x out btm0cy flag setting pulse 5 v 0 v h l h l h l device opeation stops halt status 50 ms oscillation starts program starts from address 0
321 m pd17704, 17705, 17707, 17708, 17709 21.6 wdt&sp reset wdt&sp reset includes the following: ? watchdog timer reset ? stack pointer overflow/underflow reset figure 21-11. outline of wdt&sp reset 21.6.1 watchdog timer reset the watchdog timer is a circuit that generates a reset signal when the execution sequence of the program is abnormal (hung-up). hanging-up means that the program jumps to an unexpected routine due to external noise, entering a specific infinite loop and causing the system to be deadlocked. by using the watchdog timer, the program can be restored from this hang-up status because a reset signal is generated from the watchdog timer at fixed time intervals and program execution is started from address 0. the watchdog timer does not function in the clock stop mode and halt mode. resetting by the watchdog timer initializes all the registers except the stack overflow selection register, watchdog timer counter reset register, basic timer 0 carry register, and ce reset timer carry counter. the watchdog timer reset is detected by the wdtcy flag (r&reset). instruction count clock 65536 instruction counter 131072 instruction counter stack overflow/under flow reset detection circuit wdtres aspres flag ispres flag wdtck1 flag wdtck0 falg wdtcy flag wdt&sp reset signal
322 m pd17704, 17705, 17707, 17708, 17709 21.6.2 watchdog timer setting flags these flags can be set only once after power-on reset on power application or reset by the reset pin. the wdtck0 and wdtck1 flags select an interval at which the reset signal is output. the reference time can be selected to the following three conditions: ? 655356 instructions ? 131072 instructions ? watchdog timer not set on power application, 131072 instructions are selected. if the reset signal generation interval is specified to be 131072 instructions, the watchdog timer ff must be reset at intervals not exceeding 131072 instructions. the valid reset period is from 1 to 131071 instructions. if the reset signal generation interval is 65536 instructions, the watchdog timer ff must be reset at intervals not exceeding 65536 instrutions. the valid reset period is from 1 to 65535 instructions. figure 21-12. configuration of watchdog timer clock selection register name flag symbol b 3 0 b 2 0 b 1 w d t c k 1 b 0 w d t c k 0 address 02h read/write r/w note watchdog timer clock selection power-on reset wdt&sp reset ce reset clock stop at reset 0011 0 1 0 1 does not set watchdog timer 65536 instructions setting prohibited 131072 instructions selects clock of watchdog timer fixed to 0 0 0 1 1 retained retained retained note can be written only once.
323 m pd17704, 17705, 17707, 17708, 17709 the wdtres flag is used to reset the watchdog timer counter. when this flag is set to 1, the watchdog timer counter is automatically reset. if the wdtres flag is set to 1 once within a reference time in which the wdtck0 and wdtck1 flags are set, the reset signal is not output by the watchdog timer. figure 21-13. configuration of watchdog timer counter reset register name flag symbol b 3 w d t r e s b 2 0 b 1 0 b 0 0 address 03h read/write w&reset watchdog timer counter reset power-on reset wdt&sp reset ce reset clock stop at reset u u u u 000 0 1 invalid resets watchdog timer counter resets watchdog timer counter fixed to 0 u: undefined
324 m pd17704, 17705, 17707, 17708, 17709 21.6.3 stack pointer overflow/underflow reset a reset signal is generated if the address or interrupt stack overflows or underflows. stack pointer overflow/underflow reset can be used to detect a program hang-up in the same manner as watchdog timer reset. the reset signal is generated under the following conditions: ? interrupt due to overflow or underflow of interrupt stack (4 levels) ? interrupt due to overflow or underflow of address stack (15 levels) reset by stack pointer overflow or underflow initializes all the registers, except the stack overflow selection register, watchdog timer counter reset register, basic timer 0 carry register, and ce reset timer carry counter. generation of stack pointer overflow or underflow reset is detected by the wdtcy flag (r&reset). 21.6.4 stack pointer setting flag the stack overflow/underflow reset selection register can be set only once after power-on reset on power application or reset by the reset pin. this register specifies whether reset by address stack overflow or underflow and reset by interrupt stack overflow or underflow are enabled or disabled.
325 m pd17704, 17705, 17707, 17708, 17709 figure 21-14. configuration of stack overflow/underflow reset selection register note can be written only once. name flag symbol b 3 0 b 2 0 b 1 i s p r e s b 0 a s p r e s address 05h read/write r/w note stack overflow/underflow reset selection power-on reset wdt&sp reset ce reset clock stop at reset 0011 0 1 disables reset enables reset selects address stack overflow/underflow reset 0 1 disables reset enables reset selects interrupt stack overflow/underflow reset fixed to ? retained retained retained
326 m pd17704, 17705, 17707, 17708, 17709 figure 21-15. configuration of wdt&sp reset selection register name flag symbol b 3 0 b 2 0 b 1 0 b 0 w d t c y address 16h read/write r&reset wdt&sp reset status detection power-on reset wdt&sp reset ce reset clock stop at reset 0000 1 r r 0 1 no reset request reset request detects occurrence of wdt&sp reset fixed to 0 r: retained
327 m pd17704, 17705, 17707, 17708, 17709 21.7 power failure detection power failure detection is used to identify whether the device has been reset by application of supply voltage v dd , reset pin, or ce pin. because the contents of the data memory and output ports are undefined on power application, these contents are initialized by using power failure detection. power failure detection can be performed in two ways: by detecting the btm0cy flag and the contents of the data memory (ram judgment). 21.7.1 and 21.7.2 describe the power failure detection circuit and power failure detection by using the btm0cy flag. 21.7.3 and 21.7.4 describe power failure detection by ram judgment method. figure 21-16. power failure detection flowchart program starts power failure detection not power failure power failure initializes data memory and output ports 21.7.1 power failure detection circuit the power failure detection circuit consists of a voltage detection circuit, and basic timer 0 carry disable flip-flop that is set by the output (power-on clear signal) of the voltage detection circuit, and timer carry, as shown in figure 21-1. the basic timer 0 carry disable ff is set to 1 by the power-on clear signal, and is reset to 0 when an instruction that reads the btm0cy flag is executed. when the basic timer 0 carry disable ff is set to 1, the btm0cy flag is not set to 1. if the power-on clear signal is output (at power-on reset), the program starts with the btm0cy flag reset. after that, the btm0cy flag is disabled from being set until an instruction that reads the flag is executed. once the instruction that reads this flag has been executed, the btm0cy flag is set each time the basic timer 0 carry ff setting pulse rises. therefore, by detecting the content of the btm0cy flag when the device is reset, whether the device has been reset by power-on reset (power failure) or ce reset (not power failure) can be identified. that is, the device has been reset by power-on reset if the btm0cy flag has been reset to 0. it has been reset by ce reset if the flag has been set to 1. because the voltage at which a power failure can be detected is the same as that at which power-on reset is executed, v dd = 3.5 v during crystal oscillation and v dd = 2.2 v in the clock stop status. the operation of the btm0cy flag is the same regardless of whether the device has been reset by the reset pin or by power-on reset.
328 m pd17704, 17705, 17707, 17708, 17709 21.7.2 cautions on detecting power failure by btm0cy flag the following points must be noted when counting the watch timer by using the btm0cy flag. (1) updating watch when creating a watch program using the timer carry, the watch must be updated after a power failure has been detected. this is because the btm0cy flag is reset to 0 because it is read after a power failure has been detected. as a result, counting of the watch is overlooked once. (2) watch updating processing time updating the watch must be completed before the next basic timer 0 carry ff setting pulse rises. this is because ce reset is executed before the watch updating processing has been completed if the ce pin goes high during watch updating processing. for the details of (1) and (2), refer to (3) compensating basic timer 0 carry at ce reset in 13.2.6 . the following points must be noted when performing processing in case of a power failure. (3) timing to detect power failure when counting the watch by using the btm0cy flag, the btm0cy flag must be read to detect a power failure before the next basic timer 0 carry ff setting pulse rises after the program has been started from address 0000h. this is because, if the basic timer 0 carry ff setting time is set to, say, 10 ms, and if the power failure is detected 11 ms after the program has been started, the btm0cy flag is overlooked once. for further information, refer to (3) compensating basic timer 0 carry at ce reset in 13.2.6 . power failure detection and initial processing must be performed within the time in which the basic timer 0 carry ff is set, as shown in the example below. this is because, if the ce pin rises and ce reset is executed during power failure processing or initial processing, the processing is stopped in midway, causing a problem. to update the basic timer 0 carry ff setting time in the initial processing, the instruction that changes the setting time must be executed at the end of the initial processing. this is because, if the basic timer 0 carry ff setting time is changed before the initial processing, the initial processing may not be executed to the end because ce reset may be executed.
329 m pd17704, 17705, 17707, 17708, 17709 example start: ; program address 0000h ; <1> processing at reset ; <2> skt1 btm0cy ; power failure detection br initial backup: ; <3> watch updating br main initial: ; <4> initial processing ; <5> initflg btm0ck1, btm0ck0 ; embedded macro ; sets basic timer 0 carry ff ; sets time to 10 ms main: main processing skt1 btm0cy br main watch updating br main operation example (if ce reset timer counter is set to 1) v dd ce 10-ms pluse 50-ms pluse btm0cy flag setting pulse 5 v 0 v h l h l 50 ms 10 ms 50 ms <1> <4> <1> <3> <2> <2> power failure detection if processing time of <1> + <4> is longer than 100 ms, ce reset is executed in the middle of processing <4>. <5> ce reset power failure detection if processing time of <1> + <3> is too long, ce reset is executed. ce reset ce reset may be executed immediately depending on when the basic timer 0 carry ff setting time is changed. therefore, if <5> is executed before <4>, power failure processin g <4> ma y not be executed to the end.
330 m pd17704, 17705, 17707, 17708, 17709 21.7.3 power failure detection by ram judgment method by the ram judgment method, a power failure is detected by judging whether the contents of the data memory at a specific address are a specific value when the device has been reset. an example of a program that detects a power failure by ram judgment method is shown below. by the ram judgment method, a power failure is detected by comparing an undefined value and a specific value because the contents of the data memory are undefined on application of supply voltage v dd . therefore, a power failure may be judged by mistake by this method as described in 21.7.4 cautions on power failure detection by ram judgment method . example program example of power failure detection by ram judgment method m012 mem 0.12h m034 mem 0.34h m056 mem 0.56h m107 mem 1.07h m128 mem 1.28h m16f mem 1.6fh data0 dat 1010b data1 dat 0101b data2 dat 0110b data3 dat 1001b data4 dat 1100b data5 dat 0011b start: set2 cmp, z sub m012, #data0 ; if m012 = data0, and sub m034, #data1 ; m034 = data1, and sub m056, #data2 ; m056 = data2, and bank1 sub m107, #data3 ; m107 = data3, and sub m128, #data4 ; m128 = data4, and sub m16f, #data5 ; m16f = data5, bank0 skf1 z br backup ; branches to backup ; initial: initial processing mov m012, #data0 mov m034, #data1 mov m056, #data2 bank1 mov m107, #data3 mov m128, #data4 mov m16f, #data5 br main backup: backup processing main: main processing
331 m pd17704, 17705, 17707, 17708, 17709 data memory destruction start voltage 5 v 0 v v dd values of data memor y addresses not used for ram j ud g ment ma y be destro y ed. data memory for ram judgment (normal) data memory 21.7.4 cautions on power failure detection by ram judgment method because the values of the data memory on application of supply voltage v dd are basically undefined, the following points (1) and (2) must be noted. (1) data to be compared where the number of bits of the data memory to be compared by the ram judgment method is n bits, the probability that the value of the data memory happens to coincide the value to be compared on application of v dd is (1/2) n . in other words, a power failure detected by the ram judgment method may be judged as backup at a probability of (1/2) n . to minimize this probability, compare as many bits as possible. because the contents of the data memory on application of v dd are likely to be the same value such as 0000b and 1111b, it is recommended that the data to be compared consist of a combination of 0s and 1s, such as 1010b and 0110b. (2) cautions on program if v dd rises from a level at which the contents of the data memory are destroyed as shown in figure 21-17, even if the value of the data memory to be compared is normal, the other parts of the data memory may be destroyed. if a power failure detection is performed by the ram judgment method at this time, it is judged to be a backup. therefore, the program must be designed so that a hang-up does not occur even if the contents of the data memory are destroyed. figure 21-17. v dd and destruction of data memory contents (3) cautions on using reset pin caution if the device is reset by the reset pin during program execution, the data in the data memory may be corrupted. therefore, be careful when resetting with the reset pin.
332 m pd17704, 17705, 17707, 17708, 17709 22. instruction set 22.1 outline of instruction set b 14 -b 11 b 15 01 bin hex 0000 0 add r,m add m,#n4 0001 1 sub r,m sub m, #n4 0010 2 addc r,m addc m,#n4 0011 3 subc r,m subc m,#n4 0100 4 and r,m and m,#n4 0101 5 xor r,m xor m,#n4 0110 6 or r,m or m,#n4 inc ar inc ix rorc r movt dbf,@ar push ar pop ar get dbf,p put p,dbf peek wr,rf poke rf,wr 0111 7 br @ar call @ar syscal entry ret retsk reti ei di stop s halt h nop 1000 8 ld r,m st m,r 1001 9 ske m,#n4 skge m,#n4 1010 a mov @r,m mov m,@r 1011 b skne m,#n4 sklt m,#n4 1100 c br addr (page 0) call addr (page 0) 1101 d br addr (page 1) mov m,#n4 1110 e br addr (page 2) skt m,#n4 1111 f br addr (page 3) skf m,#n
333 m pd17704, 17705, 17707, 17708, 17709 22.2 legend ar : address register asr : address stack register indicated by stack pointer addr : program memory address (low-order 11 bits) bank : bank register cmp : compare flag cy : carry flag dbf : data buffer entry : program memory address (bits 10 through 8, bits 3 through 0) entry h : program memory address (bits 10 through 8) entry l : program memory address (bits 3 through 0) h : halt release condition intef : interrupt enable flag intr : register automatically saved to stack when interrupt occurs intsk : interrupt stack register ix : index register mp : data memory row address pointer mpe : memory pointer enable flag m : data memory address indicated by m r , m c m r : data memory row address (high-order) m c : data memory column address (low-order) n : bit position (4 bits) n4 : immediate data (4 bits) page : page (bits 12 and 11 of program counter) pc : program counter p : peripheral address p h : peripheral address (high-order 3 bits) p l : peripheral address (low-order 4 bits) r : general register column address rf : register file address rf r : register file row address (high-order 3 bits) rf c : register file column address (low-order 4 bits) sgr : segment register (bit 13 of program counter) sp : stack pointer s : stop release condition wr : window register (x) : contents addressed by x
334 m pd17704, 17705, 17707, 17708, 17709 22.3 instruction list instructions mnemonic operand operation instruction code op code operand add add r,m (r) (r) + (m) 00000 m r m c r m,#n4 (m) (m) + n4 10000 m r m c n4 addc r,m (r) (r) + (m) + cy 00010 m r m c r m,#n4 (m) (m) + n4 + cy 10010 m r m c n4 inc ar ar ar + 1 00111 000 1001 0000 ix ix ix + 1 00111 000 1000 0000 subtract sub r,m (r) (r) C (m) 00001 m r m c r m,#n4 (m) (m) C n4 10001 m r m c n4 subc r,m (r) (r) C (m) C cy 00011 m r m c r m,#n4 (m) (m) C n4 C cy 10011 m r m c n4 logical or r,m (r) (r) v (m) 00110 m r m c r operation m,#n4 (m) (m) v n4 10110 m r m c n4 and r,m (r) (r) (m) 00100 m r m c r m,#n4 (m) (m) n4 10100 m r m c n4 xor r,m (r) (r) v (m) 00101 m r m c r m,#n4 (m) (m) v n4 10101 m r m c n4 judge skt m,#n cmp 0, if (m) n = n, then skip 11110 m r m c n skf m,#n cmp 0, if (m) n = 0, then skip 11111 m r m c n compare ske m,#n4 (m) C n4, skip if zero 01001 m r m c n4 skne m,#n4 (m) C n4, skip if not zero 01011 m r m c n4 skge m,#n4 (m) C n4, skip if not borrow 11001 m r m c n4 sklt m,#n4 (m) C n4, skip if borrow 11011 m r m c n4 rotate rorc r cy (r) b 3 (r) b 2 (r) b 1 (r) b 0 00111 000 0111 r transfer ld r,m (r) (m) 01000 m r m c r st m,r (m) (r) 11000 m r m c r mov @r,m if mpe = 1 : (mp, (r)) (m) 01010 m r m c r if mpe = 0 : (bank, m r , (r)) (m) m, @r if mpe = 1 : (m) (mp, (r)) 11010 m r m c r if mpe = 0 : (m) (bank, m r , (r)) m,#n4 (m) n4 11101 m r m c n4 movt dbf,@ar sp sp C 1, asr pc, pc ar, 00111 000 0001 0000 dbf (pc), pc asr, sp sp + 1 push ar sp sp C 1, asr ar 00111 000 1101 0000 pop ar ar asr, sp sp + 1 00111 000 1100 0000 get dbf,p dbf (p) 00111 p h 1011 p l put p,dbf (p) dbf 00111 p h 1010 p l peek wr,rf wr (rf) 00111 rf r 0011 rf c poke rf,wr (rf) wr 00111 rf r 0010 rf c v v v v
335 m pd17704, 17705, 17707, 17708, 17709 instructions mnemonic operand operation instruction code op code operand branch br addr pc 10C0 addr, page 0 01100 addr pc 10C0 addr, page 1 01101 pc 10C0 addr, page 2 01110 pc 10C0 addr, page 3 01111 @ar pc ar 00111 000 0100 0000 subroutine call addr sp sp C 1, asr pc 11100 addr pc 11 0, pc 10C0 addr @ar sp sp C 1, asr pc 00111 000 0101 0000 pc ar syscal entry sp sp C 1, asr pc, sgr 1 00111 entry h 0010 entry l pc 12, 11 0, pc 10C8 entry h , pc 7C4 0, pc 3C0 entry l ret pc asr, sp sp + 1 00111 000 1110 0000 retsk pc asr, sp sp + 1 and skip 00111 001 1110 0000 reti pc asr, intr intsk, sp sp + 1 00111 010 1110 0000 interrupt ei intef 1 00111 000 1111 0000 di intef 0 00111 001 1111 0000 others stop s stop 00111 010 1111 s halt h halt 00111 011 1111 h nop no operation 00111 100 1111 0000
336 m pd17704, 17705, 17707, 17708, 17709 22.4 assembler (ra17k) embedded macro instruction legend flag n : flg symbol n : bit number < > : can be omitted mnemonic operand operation n embedded sktn flag 1, ... flag n if (flag1) ~ (flag n) = all 1, then skip 1 n 4 macro skfn flag 1, ... flag n if (flag 1) ~ (flag n) = all 0, then skip 1 n 4 setn flag 1, ... flag n (flag 1) ~ (flag n) 11 n 4 clrn flag 1, ... flag n (flag 1) ~ (flag n) 01 n 4 notn flag 1, ... flag n if (flag n) = 0, then (flag n) 11 n 4 if (flag n) = 1, then (flag n) 0 initflg flag 1, if description = not flag n, then (flag n) 01 n 4 ... < flag n> if description = flag n, then (flag n) 1 bankn (bank) n0 n 15 expanded brx label jump label instruction callx function-name call sub-routine syscalx function-name or call system sub-routine expression initflgx flag 1, if description = not (or inv) n 4 ... flag n flag, (flag) 0 if description = flag, (flag) 1
337 m pd17704, 17705, 17707, 17708, 17709 23. reserved symbols 23.1 data buffer (dbf) symbol name attribute value r/w description dbf3 mem 0.0ch r/w bits 15 through 12 of data buffer dbf2 mem 0.0dh r/w bits 11 through 8 of data buffer dbf1 mem 0.0eh r/w bits 7 through 4 of data buffer dbf0 mem 0.0fh r/w bits 3 through 0 of data buffer 23.2 system registers (sysreg) symbol name attribute value r/w description ar3 mem 0.74h r/w bits 15 through 12 of address register ar2 mem 0.75h r/w bits 11 through 8 of address register ar1 mem 0.76h r/w bits 7 through 4 of address register ar0 mem 0.77h r/w bits 3 through 0 of address register wr mem 0.78h r/w window register bank mem 0.79h r/w bank register ixh mem 0.7ah r/w bits 10 through 8 of index register mph mem 0.7ah r/w bits 6 through 4 of memory pointer mpe flg 0.7ah.3 r/w memory pointer enable flag ixm mem 0.7bh r/w bits 7 through 4 of index register mpl mem 0.7bh r/w bits 3 through 0 of memory pointer ixl mem 0.7ch r/w bits 3 through 0 of index register rph mem 0.7dh r/w bits 6 through 3 of general register pointer rpl mem 0.7eh r/w bits 2 through 0 of general register pointer bcd flg 0.7eh.0 r/w bcd operation flag psw mem 0.7fh r/w program status word cmp flg 0.7fh.3 r/w compare flag cy flg 0.7fh.2 r/w carry flag z flg 0.7fh.1 r/w zero flag ixe flg 0.7fh.0 r/w index enable flag
338 m pd17704, 17705, 17707, 17708, 17709 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC 23.3 port registers symbol name attribute value r/w description p0a3 flg 0.70h.3 r/w bit 3 of port 0a p0a2 flg 0.70h.2 r/w bit 2 of port 0a p0a1 flg 0.70h.1 r/w bit 1 of port 0a p0a0 flg 0.70h.0 r/w bit 0 of port 0a p0b3 flg 0.71h.3 r/w bit 3 of port 0b p0b2 flg 0.71h.2 r/w bit 2 of port 0b p0b1 flg 0.71h.1 r/w bit 1 of port 0b p0b0 flg 0.71h.0 r/w bit 0 of port 0b p0c3 flg 0.72h.3 r/w bit 3 of port 0c p0c2 flg 0.72h.2 r/w bit 2 of port 0c p0c1 flg 0.72h.1 r/w bit 1 of port 0c p0c0 flg 0.72h.0 r/w bit 0 of port 0c p0d3 flg 0.73h.3 r note bit 3 of port 0d p0d2 flg 0.73h.2 r note bit 2 of port 0d p0d1 flg 0.73h.1 r note bit 1 of port 0d p0d0 flg 0.73h.0 r note bit 0 of port 0d p1a3 flg 1.70h.3 r note bit 3 of port 1a p1a2 flg 1.70h.2 r note bit 2 of port 1a p1a1 flg 1.70h.1 r note bit 1 of port 1a p1a0 flg 1.70h.0 r note bit 0 of port 1a p1b3 flg 1.71h.3 r/w bit 3 of port 1b p1b2 flg 1.71h.2 r/w bit 2 of port 1b p1b1 flg 1.71h.1 r/w bit 1 of port 1b p1b0 flg 1.71h.0 r/w bit 0 of port 1b p1c3 flg 1.72h.3 r note bit 3 of port 1c p1c2 flg 1.72h.2 r note bit 2 of port 1c p1c1 flg 1.72h.1 r note bit 1 of port 1c p1c0 flg 1.72h.0 r/w bit 0 of port 1c note these are input ports. however, even if an instruction that outputs data to these ports is described, the assembler and in-circuit emulator do not output an error message. moreover, nothing is affected in terms of operation even if such an instruction is actually executed on the device. CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC
339 m pd17704, 17705, 17707, 17708, 17709 symbol name attribute value r/w description p1d3 flg 1.73h.3 r/w bit 3 of port 1d p1d2 flg 1.73h.2 r/w bit 2 of port 1d p1d1 flg 1.73h.1 r/w bit 1 of port 1d p1d0 flg 1.73h.0 r/w bit 0 of port 1d p2a2 flg 2.70h.2 r/w bit 2 of port 2a p2a1 flg 2.70h.1 r/w bit 1 of port 2a p2a0 flg 2.70h.0 r/w bit 0 of port 2a p2b3 flg 2.71h.3 r/w bit 3 of port 2b p2b2 flg 2.71h.2 r/w bit 2 of port 2b p2b1 flg 2.71h.1 r/w bit 1 of port 2b p2b0 flg 2.71h.0 r/w bit 0 of port 2b p2c3 flg 2.72h.3 r/w bit 3 of port 2c p2c2 flg 2.72h.2 r/w bit 2 of port 2c p2c1 flg 2.72h.1 r/w bit 1 of port 2c p2c0 flg 2.72h.0 r/w bit 0 of port 2c p2d2 flg 2.73h.2 r/w bit 2 of port 2d p2d1 flg 2.73h.1 r/w bit 1 of port 2d p2d0 flg 2.73h.0 r/w bit 0 of port 2d p3a3 flg 3.70h.3 r/w bit 3 of port 3a p3a2 flg 3.70h.2 r/w bit 2 of port 3a p3a1 flg 3.70h.1 r/w bit 1 of port 3a p3a0 flg 3.70h.0 r/w bit 0 of port 3a p3b3 flg 3.71h.3 r/w bit 3 of port 3b p3b2 flg 3.71h.2 r/w bit 2 of port 3b p3b1 flg 3.71h.1 r/w bit 1 of port 3b p3b0 flg 3.71h.0 r/w bit 0 of port 3b p3c3 flg 3.72h.3 r/w bit 3 of port 3c p3c2 flg 3.72h.2 r/w bit 2 of port 3c p3c1 flg 3.72h.1 r/w bit 1 of port 3c p3c0 flg 3.72h.0 r/w bit 0 of port 3c p3d3 flg 3.73h.3 r/w bit 3 of port 3d p3d2 flg 3.72h.2 r/w bit 2 of port 3d p3d1 flg 3.73h.1 r/w bit 1 of port 3d p3d0 flg 3.73h.0 r/w bit 0 of port 3d CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC
340 m pd17704, 17705, 17707, 17708, 17709 23.4 register file (control registers) symbol name attribute value r/w description sp mem 0.81h r/w stack pointer wdtck mem 0.82h r/w watchdog timer clock selection flag (can be set only once after power application) wdtck1 flg 0.82h.1 r/w watchdog timer clock selection flag (can be set only once after power application) wdtck0 flg 0.82h.0 r/w watchdog timer clock selection flag (can be set only once after power application) wdtres flg 0.83h.3 r/w watchdog timer counter reset (when read: 0) dbfsp mem 0.84h r dbf stack pointer sprsel mem 0.85h r/w stack overflow/underflow reset selection flag (can be set only once after power application) ispres flg 0.85h.1 r/w stack overflow/underflow reset selection flag (can be set only once after power application) aspres flg 0.85h.0 r/w stack overflow/underflow reset selection flag (can be set only once after power application) cecnt3 flg 0.86h.3 r/w ce reset timer carry counter cecnt2 flg 0.86h.2 r/w ce reset timer carry counter cecnt1 flg 0.86h.1 r/w ce reset timer carry counter cecnt0 flg 0.86h.0 r/w ce reset timer carry counter movtsel1 flg 0.87h.1 r/w movt bit selection flag movtsel0 flg 0.87h.0 r/w movt bit selection flag sysrsp mem 0.88h r system register stack pointer sio0wstt flg 0.8ah.0 r serial interface 0 wait status judgment flag sbmd flg 0.8bh.2 r/w i 2 c bus slave transmission operation mode selection flag sio0ck1 flg 0.8bh.1 r/w serial interface 0 i/o clock selection flag sio0ck0 flg 0.8bh.0 r/w serial interface 0 i/o clock selection flag sio0imd3 flg 0.8ch.3 r/w serial interface 0 interrupt mode selection flag (dummy) sio0imd2 flg 0.8ch.2 r/w serial interface 0 interrupt mode selection flag (dummy) sio0imd1 flg 0.8ch.1 r/w serial interface 0 interrupt mode selection flag sio0imd0 flg 0.8ch.0 r/w serial interface 0 interrupt mode selection flag sio0sf8 flg 0.8dh.3 r 8-count detection flag of serial interface 0 clock counter sio0sf9 flg 0.8dh.2 r 9-count detection flag of serial interface 0 clock counter sbstt flg 0.8dh.1 r serial interface 0 (i 2 c mode) communication status detection flag (1: start condition detected) sbbsy flg 0.8dh.0 r serial interface 0 (i 2 c mode) communication status detection flag (1: start condition detected, 0: stop condition detected) sback flg 0.8eh.3 r/w` serial interface 0 (i 2 c mode) ack signal setting/detection flag sio0nwt flg 0.8eh.2 r/w serial interface 0 wait status setting/detection flag (1: wait status released (no wait)) sio0wrq1 flg 0.8eh.1 r/w bit 1 of serial interface 0 wait condition setting flag sio0wrq0 flg 0.8eh.0 r/w bit 0 of serial interface 0 wait condition setting flag CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC
341 m pd17704, 17705, 17707, 17708, 17709 symbol name attribute value r/w description sio0ch flg 0.8fh.3 r/w serial interface 0 mode selection flag sb flg 0.8fh.2 r/w serial interface 0 mode selection flag sio0ms flg 0.8fh.1 r/w serial interface 0 shift clock mode selection flag sio0tx flg 0.8fh.0 r/w serial interface 0 transmission (tx)/reception (rx) selection flag pllscnf flg 0.90h.3 r/w swallow counter least significant bit setting flag pllmd1 flg 0.90h.1 r/w pll mode selection flag pllmd0 flg 0.90h.0 r/w pll mode selection flag pllrfck3 flg 0.91h.3 r/w pll reference frequency selection flag pllrfck2 flg 0.91h.2 r/w pll reference frequency selection flag pllrfck1 flg 0.91h.1 r/w pll reference frequency selection flag pllrfck0 flg 0.91h.0 r/w pll reference frequency selection flag pllul flg 0.92h.0 r&reset pll unlock ff flag beep1sel flg 0.93h.1 r/w beep1/general-purpose port pin function selection flag beep0sel flg 0.93h.0 r/w beep0/general-purpose port pin function selection flag beep1ck1 flg 0.94h.3 r/w beep1 clock selection flag beep1ck0 flg 0.94h.2 r/w beep1 clock selection flag beep0ck1 flg 0.94h.1 r/w beep0 clock selection flag beep0ck0 flg 0.94h.0 r/w beep0 clock selection flag wdtcy flg 0.96h.0 r watchdog timer/stack pointer reset status detection flag btm0cy flg 0.97h.0 r basic timer 0 carry flag btm0ck1 flg 0.98h.1 r/w basic timer 0 clock selection flag btm0ck0 flg 0.98h.0 r/w basic timer 0 clock selection flag sio1ts flg 0.9dh.3 r/w serial interface 1 transmission/reception start flag sio1hiz flg 0.9dh.2 r/w serial interface 1/general-purpose port selection flag sio1ck1 flg 0.9dh.1 r/w serial interface 1 i/o clock selection flag sio1ck0 flg 0.9dh.0 r/w serial interface 1 i/o clock selection flag ieg4 flg 0.9eh.3 r/w edge direction selection flag for int4 pin interrupt request detection int4sel flg 0.9eh.2 r/w int4 pin interrupt request flag setting disable ieg3 flg 0.9eh.1 r/w edge direction selection flag for int3 pin interrupt request detection int3sel flg 0.9eh.0 r/w int3 pin interrupt request flag setting disable ieg2 flg 0.9fh.2 r/w edge direction selection flag for int2 pin interrupt request detection ieg1 flg 0.9fh.1 r/w edge direction selection flag for int1 pin interrupt request detection ieg0 flg 0.9fh.0 r/w edge direction selection flag for int0 pin interrupt request detection fcgch1 flg 0.0a0h.1 r/w fgc channel selection flag fcgch0 flg 0.0a0h.0 r/w fgc channel selection flag ifcgostt flg 0.0a1h.0 r if counter gate status detection flag (1: open, 0: closed) CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC
342 m pd17704, 17705, 17707, 17708, 17709 symbol name attribute value r/w description ifcmd1 flg 0.0a2h.3 r/w if counter mode selection flag (10: amif, 11: fcg) ifcmd0 flg 0.0a2h.2 r/w if counter mode selection flag (00: cgp, 11: fmif) ifcck1 flg 0.0a2h.1 r/w if counter clock selection flag ifcck0 flg 0.0a2h.0 r/w if counter clock selection flag ifcstrt flg 0.0a3h.1 w if counter count start flag ifcres flg 0.0a3h.0 w if counter reset flag adcch3 flg 0.0a4h.3 r/w a/d converter channel selection flag (dummy) adcch2 flg 0.0a4h.2 r/w a/d converter channel selection flag adcch1 flg 0.0a4h.1 r/w a/d converter channel selection flag adcch0 flg 0.0a4h.0 r/w a/d converter channel selection flag adcmd flg 0.0a5h.2 r/w a/d converter compare mode selection flag adcstt flg 0.0a5h.1 r a/d converter operation status detection flag (0: end of conversion, 1: conversion in progress) adccmp flg 0.0a5h.0 r a/d converter compare result detection flag pwmbit flg 0.0a6h.2 r/w pwm counter bit selection flag (0: 8 bits, 1: 9 bits) pwmck flg 0.0a6h.0 r/w pwm timer output clock selection flag pwm2sel flg 0.0a7h.2 r/w pwm2/general-purpose port pin function selection flag pwm1sel flg 0.0a7h.1 r/w pwm1/general-purpose port pin function selection flag pwm0sel flg 0.0a7h.0 r/w pwm0/general-purpose port pin function selection flag tm3sel flg 0.0a8h.3 r/w pwm/modulo timer 3 selection flag tm3en flg 0.0a8h.1 r/w modulo timer 3 count start flag tm3res flg 0.0a8h.0 r/w modulo timer 3 reset flag (when read: 0) tm2en flg 0.0a9h.3 r/w modulo timer 2 count start flag tm2res flg 0.0a9h.2 r/w modulo timer 2 reset flag (when read: 0) tm2ck1 flg 0.0a9h.1 r/w modulo timer 2 clock selection flag tm2ck0 flg 0.0a9h.0 r/w modulo timer 2 clock selection flag tm1en flg 0.0aah.3 r/w modulo timer 1 count start flag tm1res flg 0.0aah.2 r/w modulo timer 1 reset flag (when read: 0) tm1ck1 flg 0.0aah.1 r/w modulo timer 1 clock selection flag tm1ck0 flg 0.0aah.0 r/w modulo timer 1 clock selection flag tm0en flg 0.0abh.3 r/w modulo timer 0 count start flag tm0res flg 0.0abh.2 r/w modulo timer 0 reset flag (when read: 0) tm0ck1 flg 0.0abh.1 r/w modulo timer 0 clock selection flag tm0ck0 flg 0.0abh.0 r/w modulo timer 0 clock selection flag tm0ovf flg 0.0ach.3 r modulo timer 0 overflow detection flag tm0gceg flg 0.0ach.2 r/w modulo timer 0 gate close input signal edge selection flag tm0goeg flg 0.0ach.1 r/w modulo timer 0 gate open input signal edge selection flag tm0md flg 0.0ach.0 r/w modulo timer 0 modulo counter/gate counter selection flag CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC
343 m pd17704, 17705, 17707, 17708, 17709 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC symbol name attribute value r/w description ipsio1 flg 0.0adh.3 r/w serial interface 1 interrupt enable flag ipsio0 flg 0.0adh.2 r/w serial interface 0 interrupt enable flag iptm3 flg 0.0adh.1 r/w pwm timer interrupt enable flag iptm2 flg 0.0adh.0 r/w modulo timer 2 interrupt enable flag iptm1 flg 0.0aeh.3 r/w modulo timer 1 interrupt enable flag iptm0 flg 0.0aeh.2 r/w modulo timer 0 interrupt enable flag ip4 flg 0.0aeh.1 r/w int4 pin interrupt enable flag ip3 flg 0.0aeh.0 r/w int3 pin interrupt enable flag ip2 flg 0.0afh.3 r/w int2 pin interrupt enable flag ip1 flg 0.0afh.2 r/w int1 pin interrupt enable flag ip0 flg 0.0afh.1 r/w int0 pin interrupt enable flag ipce flg 0.0afh.0 r/w ce pin interrupt enable flag irqsio1 flg 0.0b4h.0 r/w serial interface 1 interrupt request detection flag irqsio0 flg 0.0b5h.0 r/w serial interface 0 interrupt request detection flag irqtm3 flg 0.0b6h.0 r/w pwm timer interrupt request detection flag irqtm2 flg 0.0b7h.0 r/w modulo timer 2 interrupt request detection flag irqtm1 flg 0.0b8h.0 r/w modulo timer 1 interrupt request detection flag irqtm0 flg 0.0b9h.0 r/w modulo timer 0 interrupt request detection flag int4 flg 0.0bah.3 r int4 pin status detection flag irq4 flg 0.0bah.0 r/w int4 pin interrupt request detection flag int3 flg 0.0bbh.3 r int3 pin status detection flag irq3 flg 0.0bbh.0 r/w int3 pin interrupt request detection flag int2 flg 0.0bch.3 r int2 pin status detection flag irq2 flg 0.0bch.0 r/w int2 pin interrupt request detection flag int1 flg 0.0bdh.3 r int1 pin status detection flag irq1 flg 0.0bdh.0 r/w int1 pin interrupt request detection flag int0 flg 0.0beh.3 r int0 pin status detection flag irq0 flg 0.0beh.0 r/w int0 pin interrupt request detection flag ce flg 0.0bfh.3 r ce pin status detection flag cecntstt flg 0.0bfh.1 r ce reset counter status detection flag irqce flg 0.0bfh.0 r/w ce pin interrupt request detection flag p0dpld3 flg 15.66h.3 r/w p0d3 pin pull-down resistor selection flag p0dpld2 flg 15.66h.2 r/w p0d2 pin pull-down resistor selection flag p0dpld1 flg 15.66h.1 r/w p0d1 pin pull-down resistor selection flag p0dpld0 flg 15.66h.0 r/w p0d0 pin pull-down resistor selection flag CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC
344 m pd17704, 17705, 17707, 17708, 17709 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC symbol name attribute value r/w description p3dgio flg 15.67h.3 r/w p3d input/output selection flag p3cgio flg 15.67h.2 r/w p3c input/output selection flag p3bgio flg 15.67h.1 r/w p3b input/output selection flag p3agio flg 15.67h.0 r/w p3a input/output selection flag p2dbio3 flg 15.68h.3 r/w p2d3 input/output selection flag (dummy) p2dbio2 flg 15.68h.2 r/w p2d2 input/output selection flag p2dbio1 flg 15.68h.1 r/w p2d1 input/output selection flag p2dbio0 flg 15.68h.0 r/w p2d0 input/output selection flag p2cbio3 flg 15.69h.3 r/w p2c3 input/output selection flag p2cbio2 flg 15.69h.2 r/w p2c2 input/output selection flag p2cbio1 flg 15.69h.1 r/w p2c1 input/output selection flag p2cbio0 flg 15.69h.0 r/w p2c0 input/output selection flag p2bbio3 flg 15.6ah.3 r/w p2b3 input/output selection flag p2bbio2 flg 15.6ah.2 r/w p2b2 input/output selection flag p2bbio1 flg 15.6ah.1 r/w p2b1 input/output selection flag p2bbio0 flg 15.6ah.0 r/w p2b0 input/output selection flag p2abio3 flg 15.6bh.3 r/w p2a3 input/output selection flag (dummy) p2abio2 flg 15.6bh.2 r/w p2a2 input/output selection flag p2abio1 flg 15.6bh.1 r/w p2a1 input/output selection flag p2abio0 flg 15.6bh.0 r/w p2a0 input/output selection flag p1dbio3 flg 15.6ch.3 r/w p1d3 input/output selection flag p1dbio2 flg 15.6ch.2 r/w p1d2 input/output selection flag p1dbio1 flg 15.6ch.1 r/w p1d1 input/output selection flag p1dbio0 flg 15.6ch.0 r/w p1d0 input/output selection flag p0cbio3 flg 15.6dh.3 r/w p0c3 input/output selection flag p0cbio2 flg 15.6dh.2 r/w p0c2 input/output selection flag p0cbio1 flg 15.6dh.1 r/w p0c1 input/output selection flag p0cbio0 flg 15.6dh.0 r/w p0c0 input/output selection flag p0bbio3 flg 15.6eh.3 r/w p0b3 input/output selection flag p0bbio2 flg 15.6eh.2 r/w p0b2 input/output selection flag p0bbio1 flg 15.6eh.1 r/w p0b1 input/output selection flag p0bbio0 flg 15.6eh.0 r/w p0b0 input/output selection flag p0abio3 flg 15.6fh.3 r/w p0a3 input/output selection flag p0abio2 flg 15.6fh.2 r/w p0a2 input/output selection flag p0abio1 flg 15.6fh.1 r/w p0a1 input/output selection flag p0abio0 flg 15.6fh.0 r/w p0a0 input/output selection flag CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C CCCCCCCCCCCC
345 m pd17704, 17705, 17707, 17708, 17709 23.5 peripheral hardware registers symbol name attribute value r/w description adcr dat 02h r/w a/d converter reference voltage setting register sio0sfr dat 03h r/w serial interface 0 presettable shift register sio1sfr dat 04h r/w serial interface 1 presettable shift register tm0m dat 1ah r/w timer modulo 0 register tm0c dat 1bh r timer modulo 0 counter tm1m dat 1ch r/w timer modulo 1 register tm1c dat 1dh r timer modulo 1 counter tm2m dat 1eh r/w timer modulo 2 register tm2c dat 1fh r timer modulo 2 counter ar dat 40h r/w address register dbfstk dat 41h r/w dbf stack register pllr dat 42h r/w pll data register ifc dat 43h r if counter data register pwmr0 dat 44h r/w pwm0 data register pwmr1 dat 45h r/w pwm1 data register pwmr2 dat 46h r/w pwm2 data register tm3m dat 46h r/w timer modulo 3 register 23.6 others symbol name attribute value description dbf dat 0fh operand of get/put/movt/movth/movl instruction (dbf) ix dat 01h operand of inc instruction (ix) ar_epa1 dat 8040h operand of call/br/movt/movth/movtl instruction (epa bit on) ar_epa0 dat 4040h operand of call/br/movt/movth/movtl instruction (epa bit off)
346 m pd17704, 17705, 17707, 17708, 17709 24. electrical characteristics absolute maximum ratings (t a = 25 c) parameter symbol condition rating unit supply voltage v dd C0.3 ~ +6.0 v input voltage v i other than ce, int0 through int4, and reset pins C0.3 ~ v dd +0.3 v ce, int0 through int4, and reset pins C0.3 ~ v dd +0.6 v output voltage v o except p1b0 through p1b3 C0.3 ~ v dd +0.3 ma high-level output current i oh 1 pin C8.0 ma total of p2a0 through p2a2, p3a0 through p3a3, C15.0 ma and p3b0 through p3b3 total of p0a0 through p0a3, p0b0 through p0b3, C25.0 ma p0c0 through p0c3, p1d0 through p1d3, p2b0 through p2b3, p2c0 through p2c3, p2d0 through p2d2, p3c0 through p3c3, and p3d0 through p3d3 low-level output current i ol 1 pin of p1b0 through p1b3 12.0 ma 1 pin of p1b0 through p1b3 8.0 ma total of p2a0 through p2a2, p3a0 through p3a3, 15.0 ma and p3b0 through p3b3 total of p0a0 through p0a3, p0b0 through p0b3, 25.0 ma p0c0 through p0c3, p1d0 through p1d3, p2b0 through p2b3, p2c0 through p2c3, p2d0 through p2d2, p3c0 through p3c3, and p3d0 through p3d3 total of p1b0 through p1b3 pins 25.0 ma output voltage v bds p1b0-p1b3 14.0 v total power dissipation p t 200 mw operating ambient t a C40 ~ +85 c temperature storage temperature t stg C55 ~ +125 c caution if the rated value of even one of the above parameters is exceeded even momentarily, the quality of the product may be degraded. the absolute maximum ratings define the rated values exceeding which the product may be physically damaged. never exceed these ratings. recommended operating range (t a = C40 to +85 c) parameter symbol condition min. typ. max. unit supply voltage v dd1 when cpu and pll are operating 4.5 5.0 5.5 v v dd2 when cpu and pll are stopped 3.5 5.0 5.5 v recommended output voltage (t a = C40 to +85 c) parameter symbol condition min. typ. max. unit output voltage v bds p1b0-p1b3 12 v
347 m pd17704, 17705, 17707, 17708, 17709 dc characteristics (t a = C40 to +85 c, v dd = 3.5 to 5.5 v) parameter symbol condition min. typ. max. unit supply current i dd1 when cpu is operating and pll is stopped with 1.5 3.0 ma sine wave input to x in pin. (f in = 4.5 mhz 1%, v in = v dd ) i dd2 when cpu and pll are stopped with sine wave 0.7 1.5 ma input to x in pin. (f in = 4.5 mhz 1%, v in = v dd ) with halt instruction data retention voltage v ddr1 crystal oscillation 3.5 5.5 v v ddr2 crystal power failure detection by timer ff 2.2 5.5 v v ddr3 oscillation stops data memory retained 2.0 5.5 v data retention current i ddr1 crystal v dd = 5 v, t a = 25 c 2.0 4.0 m a i ddr2 oscillation stops 2.0 30.0 m a high-level input voltage v ih1 p0a0, p0b1, p0c0-p0c3, p1a0, p1a1, p1c0-p1c3, 0.7v dd v dd v p1d0-p1d3, p2a2, p2b0-p2b3, p2c0-p2c3, p2d0-p2d2, p3a0-p3a3, p3b0-p3b3, p3c0-p3c3, p3d0-p3d3 v ih2 p0a1-p0a3, p0b0, p0b2, p0b3, p2a0, p2a1, ce, 0.8v dd v dd v int0-int4, reset v ih3 p0d0-p0d3 0.55v dd v dd v low-level input voltage v il1 p0a0, p0b1, p0c0-p0c3, p1a0, p1a1, p1c0-p1c3, 0 0.3v dd v p1d0-p1d3, p2a2, p2b0-p2b3, p2c0-p2c3, p2d0-p2d2, p3a0-p3a3, p3b0-p3b3, p3c0-p3c3, p3d0-p3d3 v il2 p0a1-p0a3, p0b0, p0b2, p0b3, p2a0, p2a1, ce, 0 0.2v dd v int0-int4, reset v il3 p0d0-p0d3 0 0.15v dd v high-level output current i oh1 p0a0-p0a3, p0b0-p0b3, p0c0-p0c3, p1d0-p1d3, C1.0 ma p2a0-p2a2, p2b0-p2b3, p2c0-p2c3, p2d0-p2d2, p3a0-p3a3, p3b0-p3b3, p3c0-p3c3, p3d0-p3d3 v oh = v dd C1 v i oh2 eo0, eo1 v dd = 4.5~5.5 v, v oh = v dd C1 v C3.0 ma low-level output current i ol1 p0a0-p0a3, p0b0-p0b3, p0c0-p0c3, p1d0-p1d3, 1.0 ma p2a0-p2a2, p2b0-p2b3, p2c0-p2c3, p2d0-p2d2, p3a0-pa3a, p3b0-p3b3, p3c0-p3c3, p3d0-p3d3 v ol = 1 v i ol2 eo0, eo1 v dd = 4.5 ~ 5.5 v, v ol = 1 v 3.0 ma i ol3 p1b0-p1b3 v ol = 1 v 7.0 ma high-level input current i ih p0d0 through p0d3 pulled down v in = v dd 5.0 150 m a output off leakage i lo1 p1b0-p1b3 v in = 12 v 1.0 m a current i lo2 eo0, eo1 v in = v dd , v in = 0 v 1.0 m a high-level input leakage i lih input pin v in = v dd 1.0 m a current low-level input leakage i lil input pin v in = 0 v C1.0 m a current
348 m pd17704, 17705, 17707, 17708, 17709 ac characteristics (t a = C40 to +85 c, v dd = 5 v 10%) parameter symbol condition min. typ. max. unit operating frequency f in1 vcol pin, mf mode, sine wave input 0.5 3 mhz v in = 0.1 v p-p note f in2 vcol pin, hf mode, sine wave input 10 40 mhz v in = 0.1 v p-p note f in3 vcoh pin, vhf mode, sine wave input 60 130 mhz v in = 0.1 v p-p note f in4 amifc pin, sine wave input 0.4 0.5 mhz v in = 0.15 v p-p note f in5 fmifc pin, fmif count mode, sine wave input 10 11 mhz v in = 0.20 v p-p f in6 fmifc pin, amif count mode, sine wave input 0.4 0.5 mhz v in = 0.15 v p-p sio0 input frequency f in7 external clock 1 mhz sio1 input frequency f in8 external clock 0.7 mhz note the condition of sine wave input v in = 0.1 v p-p is the rated value when the m pd17704, 17705, 17707, 17708, or 17709 alone is operating. where influence of noise must be taken into consideration, operation under input amplitude condition of v in = 0.15 v p-p is recommended. a/d converter characteristics (t a = C40 to +85 c, v dd = 5 v 10%) parameter symbol condition min. typ. max. unit a/d conversion total error 8 bit 3.0 lsb a/d conversion total error 8 bit t a = 0 ~ 85 c 2.5 lsb reference characteristics (t a = +25 c, v dd = 5.0 v) parameter symbol condition min. typ. max. unit supply current i dd3 when cpu and pll are operating with sine wave 6.0 12.0 ma input to vcoh pin (f in = 130 mhz, v in = 0.3 v p-p )
349 m pd17704, 17705, 17707, 17708, 17709 25. package drawing remark the dimensions and materials of the es model are the same as those of the mass-produced model. 80 pin plastic qfp (14 14) item millimeters inches note each lead centerline is located within 0.13 mm (0.005 inch) of its true position (t.p.) at maximum material condition. l 0.8?.2 0.031 +0.009 ?.008 m 0.15 0.006 n 0.10 0.004 p 2.7 0.106 a 17.2?.4 0.677?.016 b 14.0?.2 0.551 +0.009 ?.008 c 14.0?.2 0.551 +0.009 ?.008 d 17.2?.4 0.677?.016 f 0.825 0.032 g 0.825 0.032 h 0.30?.10 0.012 +0.004 ?.005 i 0.13 0.005 j 0.65 (t.p.) 0.026 (t.p.) q 0.1?.1 0.004?.004 r5 ? 5 ? +0.10 ?.05 +0.004 ?.003 m m l k j h q p n r detail of lead end i g k 1.6?.2 0.063?.008 60 61 40 80 1 21 20 41 a b cd f s s80gc-65-3b9-4 s 3.0 max. 0.119 max.
350 m pd17704, 17705, 17707, 17708, 17709 26. recommended soldering conditions solder the m pd17709 under the following recommended conditions. for the details of the recommended soldering conditions, refer to semiconductor device mounting technology manual (c10535e) . for the soldering method and conditions other than those recommended, consult nec. table 26-1. soldering conditions of surface mount type m pd17704gc-xxx-3b9: 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17705gc-xxx-3b9: 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17707gc-xxx-3b9: 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17708gc-xxx-3b9: 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) m pd17709gc-xxx-3b9: 80-pin plastic qfp (14 14 mm, 0.65 mm pitch) symbol of soldering method soldering condition recommended condition infrared reflow package peak temperature: 235 c, time: 30 seconds max. (210 c min.) ir35-00-2 number of times: 2 max. vps package peak temperature: 215 c, time: 40 seconds max. (200 c min.) vp15-00-2 number of times: 2 max. wave soldering soldering bath temperature: 260 c max., time: 10 seconds max., number of times: 1, ws60-00-1 preheating temperature: 120 c max. (package surface temperature) partial heating pin temperature: 300 c max., time: 3 seconds max. (per side of device) caution do not use two or more soldering methods in combination (except partial heating method).
351 m pd17704, 17705, 17707, 17708, 17709 appendix a. cautions on connecting crystal resonator when using the system clock oscillation circuit, wire the portion enclosed by the dotted line in the figure below as follows to prevent adverse influence from wiring capacity. ? keep the wiring length as short as possible. ? if capacitances c1 and c2 are too high, the oscillation start characteristics may be degraded or current consumption may increase. ? generally, connect a trimmer capacitor for adjusting the oscillation frequency to the x in pin. depending on the crystal resonator to be used, however, the oscillation stability differs. therefore, evaluate the crystal resonator actually used. ? the crystal oscillation frequency cannot be accurately adjusted when an emulation probe is connected to the x out and x in pin, because of the capacitance of the probe. adjust the frequency while measuring the vco oscillation frequency. pd17709 4.5-mhz crystal resonator c1 c2 x out x in m
352 m pd17704, 17705, 17707, 17708, 17709 appendix b. development tools the following development tools are available for development of programs for the m pd17709. hardware name outline ie-17k, ie-17k-et, and emu-17k are in-circuit emulators that can be used with any model in the 17k series. ie-17k and ie-17k-et are connected to a host machine, which is pc-9800 series or ibm pc/at tm , with rs-232c. emu-17k is mounted to the expansion slot of a host machine, pc-9800 series. by using these in-circuit emulators with a system evaluation board (se board) corresponding to each model, these emulators operate dedicated to the model. when man-machine interface software simplehost tm is used, a more sophisticated debugging environment can be created. emu-17k also has a function to allow you to check the contents of the data memory real-time. se-17709 is an se board for the m pd17709 subseries. this board can be used alone to evaluate a system, or in combination with an in-circuit emulator for debugging. ep-17k80gc is an emulation probe for the m pd17709 subseries. by using this probe with ev- 9200gc-80 note 3 , the se board and target system are connected. ev-9200gc-80 is a conversion socket for 80-pin plastic qfp (14 14 mm). it is used to connect ep- 17k80gc and target system. pg-1500 is a prom programmer supporting m pd17p709. it can program m pd17p709 when connected with pg-1500 adapter pa-17kdz and programmer adapter pa-17p709gc. pa-17p709gc is an adapter to program m pd17p709. it is used with pg-1500. notes 1. low-price model: external power supply type 2. this is a product of i.c corp. for details, consult i.c corp. ((03) 3447-3793). 3. one ev-9200gc-80 is supplied with the ep-17k80gc. five ev-9200gc-80 are also available as a set. remark third party prom programmers af-9703, af-9704, af-9705, and af-9706 are available from ando electric co., ltd. use these programmers with programmer adapter pa-17p709gc. for details, consult ando electric co., ltd. ((03) 3733-1163). in-circuit emulator ie-17k ie-17k-et note 1 emu-17k note 2 se board (se-17709) emulation probe (ep-17k80gc) conversion socket (ev-9200gc-80 note 3 ) prom programmer (pg-1500) programmer adapter (pa-17p709gc)
353 m pd17704, 17705, 17707, 17708, 17709 software name outline host machine os media parts number 17k series pc-9800 series ms-dos tm 5 2hd m s5a10as17k assembler 3.5 2hd m s5a13as17k (as17k) ibm pc/at pc dos tm 5 2hc m s7b10as17k 3.5 2hc m s7b13as17k device file pc-9800 series ms-dos 5 2hd m s5a10as17707 (as17707) 3.5 2hd m s5a13as17707 ibm pc/at pc dos 5 2hc m s7b10as17707 3.5 2hc m s7b13as17707 support pc-9800 series ms-dos windows 5 2hd m s5a10ie17k software 3.5 2hd m s5a13ie17k ( simplehost ) ibm pc/at pc dos 5 2hc m s7b10ie17k 3.5 2hc m s7b13ie17k remark the version of the supported os is as follows: os version ms-dos ver.3.30 ~ ver.5.00a note pc dos ver.3.1~ver.5.0 note windows ver.3.0~ver.3.1 note ms-dos ver. 5.00/5.00a and pc dos ver. 5.0 have a task swap function, but this function cannot be used with this software. as17k is an assembler that can be commonly used with 17k series. to develop programs for the m pd17709, this as17k and a device file (as17707) are used in combination. as17707 is a device file for the m pd17709 subseries. it is used with the assembler common to the 17k series (as17k). simplehost is man-machine interface software that runs on windows tm when a program is developed by using an in-circuit emulator and personal computer.
354 m pd17704, 17705, 17707, 17708, 17709 notes for cmos devices 1 precaution against esd for semiconductors note: strong electric field, when exposed to a mos device, can cause destruction of the gate oxide and ultimately degrade the device operation. steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it once, when it has occurred. environmental control must be adequate. when it is dry, humidifier should be used. it is recommended to avoid using insulators that easily build static electricity. semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. all test and measurement tools including work bench and floor should be grounded. the operator should be grounded using wrist strap. semiconductor devices must not be touched with bare hands. similar precautions need to be taken for pw boards with semiconductor devices on it. 2 handling of unused input pins for cmos note: no connection for cmos device inputs can be cause of malfunction. if no connection is provided to the input pins, it is possible that an internal input level may be generated due to noise, etc., hence causing malfunction. cmos device behave differently than bipolar or nmos devices. input levels of cmos devices must be fixed high or low by using a pull-up or pull-down circuitry. each unused pin should be connected to v dd or gnd with a resistor, if it is considered to have a possibility of being an output pin. all handling related to the unused pins must be judged device by device and related specifications governing the devices. 3 status before initialization of mos devices note: power-on does not necessarily define initial status of mos device. produc- tion process of mos does not define the initial operation status of the device. immediately after the power source is turned on, the devices with reset function have not yet been initialized. hence, power-on does not guarantee out-pin levels, i/o settings or contents of registers. device is not initialized until the reset signal is received. reset operation must be executed imme- diately after power-on for devices having reset function.
355 m pd17704, 17705, 17707, 17708, 17709 nec electronics inc. (u.s.) santa clara, california tel: 800-366-9782 fax: 800-729-9288 nec electronics (germany) gmbh duesseldorf, germany tel: 0211-65 03 02 fax: 0211-65 03 490 nec electronics (uk) ltd. milton keynes, uk tel: 01908-691-133 fax: 01908-670-290 nec electronics italiana s.r.1. milano, italy tel: 02-66 75 41 fax: 02-66 75 42 99 nec electronics hong kong ltd. hong kong tel: 2886-9318 fax: 2886-9022/9044 nec electronics hong kong ltd. seoul branch seoul, korea tel: 02-528-0303 fax: 02-528-4411 nec electronics singapore pte. ltd. united square, singapore 1130 tel: 253-8311 fax: 250-3583 nec electronics taiwan ltd. taipei, taiwan tel: 02-719-2377 fax: 02-719-5951 nec do brasil s.a. sao paulo-sp, brasil tel: 011-889-1680 fax: 011-889-1689 nec electronics (germany) gmbh benelux office eindhoven, the netherlands tel: 040-2445845 fax: 040-2444580 nec electronics (france) s.a. velizy-villacoublay, france tel: 01-30-67 58 00 fax: 01-30-67 58 99 nec electronics (france) s.a. spain office madrid, spain tel: 01-504-2787 fax: 01-504-2860 nec electronics (germany) gmbh scandinavia office taeby, sweden tel: 08-63 80 820 fax: 08-63 80 388 regional information some information contained in this document may vary from country to country. before using any nec product in your application, please contact the nec office in your country to obtain a list of authorized representatives and distributors. they will verify: ? device availability ? ordering information ? product release schedule ? availability of related technical literature ? development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, ac supply voltages, and so forth) ? network requirements in addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country. j96. 8
2 m pd17704, 17705, 17707, 17708, 17709 the export of this product from japan is regulated by the japanese government. to export this product may be prohibited without governmental license, the need for which must be judged by the customer. the export or re-export of this product from a country other than japan may also be prohibited without a license from that country. please call an nec sales representative. simplehost is a trademark of nec corporation. ms-dos and windows are trademarks of microsoft corporation. pc/at and pc dos are trademarks of ibm corporation. purchase of nec i 2 c components conveys a license under the philips i 2 c patent rights to use these components in an i 2 c system, provided that the system conforms to the i 2 c standard specification as defined by philips. no part of this document may be copied or reproduced in any form or by any means without the prior written consent of nec corporation. nec corporation assumes no responsibility for any errors which may appear in this document. nec corporation does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from use of a device described herein or any other liability arising from use of such device. no license, either express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of nec corporation or others. while nec corporation has been making continuous effort to enhance the reliability of its semiconductor devices, the possibility of defects cannot be eliminated entirely. to minimize risks of damage or injury to persons or property arising from a defect in an nec semiconductor device, customers must incorporate sufficient safety measures in its design, such as redundancy, fire-containment, and anti-failure features. nec devices are classified into the following three quality grades: "standard", "special", and "specific". the specific quality grade applies only to devices developed based on a customer designated "quality assurance program" for a specific application. the recommended applications of a device depend on its quality grade, as indicated below. customers must check the quality grade of each device before using it in a particular application. standard: computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots special: transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support) specific: aircrafts, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems or medical equipment for life support, etc. the quality grade of nec devices is "standard" unless otherwise specified in nec's data sheets or data books. if customers intend to use nec devices for applications other than those specified for standard quality grade, they should contact an nec sales representative in advance. anti-radioactive design is not implemented in this product. m4 96.5


▲Up To Search▲   

 
Price & Availability of UPD17705GC-XXX-3B9

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X